Locate patterns within a string
Arguments
- string
Character vector of strings.
- pattern
A pattern to match. Can be:
A single string or
regex(), to use POSIX 1003.2 extended regular expression.fixed()to use a fixed/literal matchi.perl()to use a Perl-compatible regular expression.
Unlike stringr,
patternmust be length 1; it will not be recycled to the same length asstring.
Value
For str_locate(), an integer matrix with one row for each element of
string, and two columns ("start" and "end"). If the match is of length 0,
end will be one character less than start.
For str_locate_all(), a list with one element for each element of string.
Each list element is integer matrix with one row for each matche, and two
columns ("start" and "end").