re2_split | R Documentation |
Vectorized over string and pattern.
re2_split(string, pattern, simplify = FALSE, n = Inf)
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). |
simplify |
If FALSE, the default, return a list of string vectors. If TRUE, return a string matrix. |
n |
Number of string pieces to return. Default (Inf) returns all. |
A list of string vectors or a string matrix. See option.
re2_regexp
for options to regular expression,
re2_syntax for regular expression syntax, and
re2_match
to extract matched groups.
panagram <- c(
"The quick brown fox jumps over the lazy dog",
"How vexingly quick daft zebras jump!"
)
re2_split(panagram, " quick | over | zebras ")
re2_split(panagram, " quick | over | zebras ", simplify = TRUE)
# Use compiled regexp
re <- re2_regexp("quick | over |how ", case_sensitive = FALSE)
re2_split(panagram, re)
re2_split(panagram, re, simplify = TRUE)
# Restrict number of matches
re2_split(panagram, " quick | over | zebras ", n = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.