re_substitutes {rex} | R Documentation |
Substitute regular expressions in a string with another string.
Description
Substitute regular expressions in a string with another string.
Usage
re_substitutes(data, pattern, replacement, global = FALSE, options = NULL, ...)
Arguments
data |
character vector to substitute |
pattern |
regular expression to match |
replacement |
replacement text to use |
global |
substitute all occurrences |
options |
option flags |
... |
options passed to sub or gsub |
See Also
regexp
Section "Perl-like Regular Expressions" for a
discussion of the supported options
Examples
string <- c("this is a Test", "string")
re_substitutes(string, "test", "not a test", options = "insensitive")
re_substitutes(string, "i", "x", global = TRUE)
re_substitutes(string, "(test)", "not a \\1", options = "insensitive")
[Package rex version 1.2.1 Index]