rex (version 1.1.2)

re_substitutes: 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

Run this code
# NOT RUN {
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")
# }

Run the code above in your browser using DataCamp Workspace