Description Usage Arguments Value Examples
View source: R/match_pattern.R
Given a pattern and a character vector, the function will extract
parts of these characters that match
the pattern. It is simply a wrapper of regmatches
.
1 | match_pattern(pattern, where, vec_result = TRUE, perl = FALSE)
|
pattern |
a length 1 regular expression to be matched. |
where |
a character vector, each of its elements may or may not have parts that match the specified pattern. |
vec_result |
should be |
perl |
default is |
a character vector or a list. If an element in where
is NA
, the result
corresponds to this element is character(0)
.
1 2 3 4 | p <- "x.*?y"
x <- c("x6yx8y", "x10yx30y", "aaaaaa", NA, "x00y")
y <- match_pattern(p, x)
y <- match_pattern(p, x, vec_result = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.