Replace matches with a pattern
Arguments
- string
Character vector of strings.
- pattern
A pattern to match. Can be:
A single string or
regex(), to use POSIX 1003.2 extended regular expression.fixed()to use a fixed/literal matchi.perl()to use a Perl-compatible regular expression.
Unlike stringr,
patternmust be length 1; it will not be recycled to the same length asstring.- replacement
A string given replace. References of the form
\1,\2, etc will be replaced with the contents of the respective matched group (created by()).