strfind.RdFind substrings within strings of a character vector.
strfind(s1, s2, overlap = TRUE)
strfindi(s1, s2, overlap = TRUE)
findstr(s1, s2, overlap = TRUE)strfind finds positions of substrings within s1 that
match exactly with s2, and is case sensitive; no regular patterns.
strfindi does not distinguish between lower and upper case.
findstr should only be used as internal function, in Matlab it is
deprecated. It searches for the shorter string within the longer one.
Returns a vector of indices, or a list of such index vectors if
s2 is a character vector of length greater than 1.
S <- c("", "ab", "aba", "aba aba", "abababa")
s <- "aba"
strfind(S, s)
#> [[1]]
#> NULL
#>
#> [[2]]
#> NULL
#>
#> [[3]]
#> [1] 1
#>
#> [[4]]
#> [1] 1 5
#>
#> [[5]]
#> [1] 1 3 5
#>
strfindi(toupper(S), s)
#> [[1]]
#> NULL
#>
#> [[2]]
#> NULL
#>
#> [[3]]
#> [1] 1
#>
#> [[4]]
#> [1] 1 5
#>
#> [[5]]
#> [1] 1 3 5
#>
strfind(S, s, overlap = FALSE)
#> [[1]]
#> NULL
#>
#> [[2]]
#> NULL
#>
#> [[3]]
#> [1] 1
#>
#> [[4]]
#> [1] 1 5
#>
#> [[5]]
#> [1] 1 5
#>