Hi, I'd like to match the beginning and the end of a string. E.g. I want to extract all strings from a vector that beginn with "12" and end with "Apples":
a <- "2 green Apples" b <- "12 green Apples" c <- "12 Apples and 2 green Bananas" d <- "12 yellow Bananas" fruitlist <- c(a,b,c,d) # This is how to extract all that beginn with 12 grepl("^12",fruitlist) But how can I get only those that also end with "Apples". So basically just item b "12 green Apples" should remain. Is there any clear description and examples of regular expressions and how to use them? I find the manual ?grepl very difficult to read. Thanks, Johannes [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.