Replace multiple text tokens with new text in provided string.
Arguments
- text
A string vector to replace tokens in.
- tbl
A two-column tibble with the
token
to replace and its correspondingnew
value.- add_breaks
A logical indicating whether to add
\\b
(word boundary) either side of each token.
Examples
# Replace multiple tokens
text <- c("Hello world!", "Goodbye world!")
tbl <- data.frame(token = c("Hello", "world"), new = c("Hi", "universe"))
multi_replace_all(text, tbl)
#> [1] "Hi universe!" "Goodbye universe!"
#> [1] "Hi universe!" "Goodbye universe!"