re2_locate | R Documentation |
Vectorized over string and pattern. For matches of 0 length (ex. spatial patterns like "$") end will be one character greater than beginning.
re2_locate(string, pattern)
re2_locate_all(string, pattern)
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). |
re2_locate
returns an integer matrix, and
re2_locate_all
returns a list of integer matrices.
re2_regexp
for options to regular expression,
re2_syntax for regular expression syntax.
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, ".")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.