multi_match | R Documentation |
Match a character vector on multiple patterns.
multi_match(
strings,
patterns,
replacements,
ignore_case = TRUE,
compress = TRUE,
first = TRUE
)
strings |
A vector of string to be matched |
patterns |
A vector of patterns to match |
replacements |
Replacement label vector of the same length as |
ignore_case |
Should case be ignored in regular expression matching? |
compress |
If |
first |
If |
If compress = TRUE
, returns a character vector. Otherwise, returns a tibble.
Sven Halvorson
strings = c('abcde', 'bc', 'def', 'gjab', 'xyz')
patterns = c('ab', 'de', 'bc')
replacements = toupper(patterns)
# Find the first match of each pattern:
multi_match(
string = strings,
patterns = patterns,
replacements = replacements
)
# Make flags for matching each pattern:
multi_match(
strings = strings,
patterns = patterns,
compress = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.