re_substitutes: Substitute regular expressions in a string with another...

Description Usage Arguments See Also Examples

Description

Substitute regular expressions in a string with another string.

Usage

1
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

1
2
3
4
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")

Example output

[1] "this is a not a test" "string"              
[1] "thxs xs a Test" "strxng"        
[1] "this is a not a Test" "string"              

rex documentation built on Nov. 26, 2021, 5:21 p.m.