Finding the indexes of multiple/overlapping matching substrings

Try gregexpr with perl=TRUE and use perl regular expressions with look-ahead assertions (see ?regex):

gregexpr("(?=CC)","CCCGTGCC",perl=TRUE)
[[1]]
[1] 1 2 7
attr(,"match.length")
[1] 0 0 0

Leave a Comment