strs_replace
replaces all occurrences of a specified substring in each
element of a character vector. It is similar to Python's str.replace()
method.
Usage
strs_replace(string, substring, replacement)
Arguments
- string
A character vector where each element is a string in which to
replace substring
.
- substring
The substring to be replaced.
- replacement
The string to replace substring
with.
Value
A character vector of the same length as string
, with substring
replaced by replacement
.
Examples
strs_replace("hello world", "world", "there")
#> [1] "hello there"
strs_replace("banana", "na", "mo")
#> [1] "bamomo"