Gabor Grothendieck wrote: > Try this. See ?regex for more. > > >> x <- 'This happened in the 21. century." (the dot behind 21 is' >> regexpr("(?![0-9]+)[.]", x, perl = TRUE) >> > [1] 24 > attr(,"match.length") > [1] 1 >
yes, but gregexpr('(?![0-9]+)[.]', 'a. 1. a1.', perl=TRUE) # 2 5 9 which, i guess, is not what you want. if what you want is to match all and only dots that follow at least one digit preceded by a word boundary, then the following should do, as far as i can see: gregexpr('\\b[0-9]+\\K[.]', 'a. 1. a1.', perl=TRUE) # 5 vQ ______________________________________________ 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.