[R] strapply and characters adjacent to the matched pattern

mdvaan mathijsdevaan at gmail.com
Tue Jul 24 23:06:42 CEST 2012


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

# load library
# 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
# match 
strapply(text, data, ignore.case = T)

The preferred outcome would be:

[1] "Santa Fe Gold Corp"

[1] "Starpharma Holdings"

instead of:

[1] "Santa Fe Gold Corp"

[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.

More information about the R-help mailing list