HI, Tried matching with data and text using strapply-Unsuccessful. But, you can get the result from the data alone if that helps you.
dat2<-strapply(data,"[^\\|]",c) list1<-list(paste(dat2[[1]][1:18],collapse=""),paste(dat2[[1]][19:37],collapse="")) list1 [[1]] [1] "Santa Fe Gold Corp" [[2]] [1] "Starpharma Holdings" A.K. ----- Original Message ----- From: mdvaan <mathijsdev...@gmail.com> To: r-help@r-project.org Cc: Sent: Tuesday, July 24, 2012 5:06 PM Subject: [R] strapply and characters adjacent to the matched pattern Hi, In the example below, one of the searched patterns "SE" is matched in the word "second". I would like to ignore all matches in which the character following the match is one of [:alpha:]. How do I do this without removing the "ignore.case = T" argument of the strapply function? Thank you very much! # load library require(gsubfn) # read in data data <- c("Santa Fe Gold Corp|Starpharma Holdings|SE") # define the object to be searched text <- c("the first is Santa Fe Gold Corp", "the second is Starpharma Holdings") # match strapply(text, data, ignore.case = T) The preferred outcome would be: [[1]] [1] "Santa Fe Gold Corp" [[2]] [1] "Starpharma Holdings" instead of: [[1]] [1] "Santa Fe Gold Corp" [[2]] [1] "se" "Starpharma Holdings" -- View this message in context: http://r.789695.n4.nabble.com/strapply-and-characters-adjacent-to-the-matched-pattern-tp4637673.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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. ______________________________________________ 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.