re2_which | R Documentation |
re2_subset
returns strings that match a pattern.
re2_which
is equivalent to grep(pattern, x). It returns
position of string that match a pattern. Vectorized over
string and pattern. For the equivalent of
grepl(pattern, x) see re2_detect
.
re2_which(string, pattern) re2_subset(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_subset
returns a character vector, and re2_which
returns an integer vector.
re2_regexp
for options to regular expression,
re2_syntax for regular expression syntax, and
re2_detect
to find presence of a pattern (grep).
color <- c("yellowgreen", "steelblue", "GOLDENROD", "forestgreen") re2_which(color, "o") re2_subset(color, "o") re2_which(c("x", "y", NA, "foo", ""), ".") re2_subset(c("x", "y", NA, "foo", ""), ".") # Use precompiled regexp re <- re2_regexp("[a-z]") re2_which(color, re) re2_subset(color, re) re <- re2_regexp("[a-z]", case_sensitive = FALSE) re2_which(color, re) re2_subset(color, re) # Vector of patterns re2_which(color, c("^o", "bl.e$", re, "$"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.