
Wrapper function for string replacement using [stringr::str_replace_all()]
Source: R/utils.R
strReplaceAll.RdWrapper function for string replacement using [stringr::str_replace_all()]
Arguments
- string
Input vector. Either a character vector, or something coercible to one.
- pattern
Pattern to look for.
The default interpretation is a regular expression, as described in stringi::about_search_regex. Control options with
regex().For
str_replace_all()this can also be a named vector (c(pattern1 = replacement1)), in order to perform multiple replacements in each element ofstring.Match a fixed string (i.e. by comparing only bytes), using
fixed(). This is fast, but approximate. Generally, for matching human text, you'll wantcoll()which respects character matching rules for the specified locale.- replacement
The replacement value, usually a single string, but it can be the a vector the same length as
stringorpattern. References of the form\1,\2, etc will be replaced with the contents of the respective matched group (created by()).Alternatively, supply a function, which will be called once for each match (from right to left) and its return value will be used to replace the match.