[R] Regular expressions: offsets of groups

Titus von der Malsburg malsburg at gmail.com
Mon Sep 27 19:34:40 CEST 2010


On Mon, Sep 27, 2010 at 7:29 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> Try this zero width negative look behind expression:
>
>> gregexpr("(?!a+)(b+)", "abcdaabbc", perl = TRUE)
> [[1]]
> [1] 2 7
> attr(,"match.length")
> [1] 1 2

Thanks Gabor, but this gives me the same result as

  gregexpr("b+", "abcdaabbc", perl = TRUE)

which is wrong if the string is "abcdaabbcbbb".

  Titus



More information about the R-help mailing list