re2_locate {re2} | R Documentation |
Locate the start and end of pattern in a string
Description
Vectorized over string and pattern. For matches of 0 length (ex. spatial patterns like "$") end will be one character greater than beginning.
Usage
re2_locate(string, pattern)
re2_locate_all(string, pattern)
Arguments
string |
A character vector, or an object which can be coerced to one. |
pattern |
Character string containing a regular expression,
or a pre-compiled regular expression (or a vector of character
strings and pre-compiled regular expressions). |
Value
re2_locate
returns an integer matrix, and
re2_locate_all
returns a list of integer matrices.
See Also
re2_regexp
for options to regular expression,
re2_syntax for regular expression syntax.
Examples
color <- c("yellowgreen", "steelblue", "goldenrod", "forestgreen")
re2_locate(color, "$")
re2_locate(color, "l")
re2_locate(color, "e")
# String length can be a multiple of pattern length
re2_locate(color, c("l(l|d)?", "st"))
# Locate all occurrences
re2_locate_all(color, "l")
re2_locate_all(color, "e")
# Locate all characters
re2_locate_all(color, ".")
[Package re2 version 0.1.3 Index]