refindall.RdFind overlapping matches for a regular expression.
refindall(s, pat, over = 1, ignorecase = FALSE)Returns the starting position of all — even overlapping — matches
of the regular expression pat in the character string s.
The syntax for pattern matching has to be PERL-like.
A numeric vector with the indices of starting positions of all matches.
This effect can also be reached with the R function gregexpr(), see the example below.
refindall("ababababa", 'aba')
#> [1] 1 3 5 7
gregexpr('a(?=ba)', "ababababa", perl=TRUE)
#> [[1]]
#> [1] 1 3 5 7
#> attr(,"match.length")
#> [1] 1 1 1 1
#> attr(,"index.type")
#> [1] "chars"
#> attr(,"useBytes")
#> [1] TRUE
#>
refindall("AbababaBa", 'aba')
#> [1] 3 5
refindall("AbababaBa", 'aba', ignorecase = TRUE)
#> [1] 1 3 5 7