str_replace_all {stringr} | R Documentation |
Vectorised over string
, pattern
and
replacement
. Shorter arguments will be expanded to
length of longest.
str_replace_all(string, pattern, replacement)
replacement |
replacement string. References of the
form |
string |
input vector. This must be an atomic vector, and will be coerced to a character vector |
pattern |
pattern to look for, as defined by a POSIX
regular expression. See the “Extended Regular
Expressions” section of |
character vector.
gsub
which this function wraps,
str_replace_all
to replace a single match
fruits <- c("one apple", "two pears", "three bananas") str_replace(fruits, "[aeiou]", "-") str_replace_all(fruits, "[aeiou]", "-") str_replace_all(fruits, "([aeiou])", "") str_replace_all(fruits, "([aeiou])", "\\1\\1") str_replace_all(fruits, "[aeiou]", c("1", "2", "3")) str_replace_all(fruits, c("a", "e", "i"), "-")