Gabor Grothendieck ggrothendieck at gmail.com writes:
Use a zero lookaround expression. It will not consume its match. See ?regexp
gregexpr(a(?=a), aaa, perl = TRUE)
[[1]]
[1] 1 2
attr(,match.length)
[1] 1 1
I wonder how you would count the number of occurrences of, for example,
Gabor Grothendieck ggrothendieck at gmail.com writes:
Try this:
findall(aba, ababacababab)
[1] 1 3 7 9
gregexpr(a(?=ba), ababacababab, perl = TRUE)
[[1]]
[1] 1 3 7 9
attr(,match.length)
[1] 1 1 1 1
findall(a.a, ababacababab)
[1] 1 3 5 7 9
gregexpr(a(?=.a), ababacababab, perl =
2 matches
Mail list logo