Match regular expression
Returns the positions of substrings that match the regular expression.
regexp(s, pat, ignorecase = FALSE, once = FALSE, split = FALSE)
regexpi(s, pat, once = FALSE, split = FALSE)
Character string, i.e. of length 1.
Matching pattern as character string.
Logical: whether case should be ignored;
Logical: whether the first are all occurrences should be found;
Logical: should the string be splitted at the occurrences of
the pattern?; default: no.
A list with components
end as numeric vectors
indicating the start and end positions of the matches.
match contains each exact match, and
split contains the
character vector of splitted strings.If no match is found all components will be
split that will contain the whole string if
split = TRUE.
Returns the start and end positions and the exact value of substrings
that match the regular expression. If
split is choosen, the
splitted strings will also be returned.
s <- "bat cat can car COAT court cut ct CAT-scan"
pat <- 'c[aeiou]+t'