stringr (version 0.5)

str_replace: Replace first occurrence of a matched pattern in a string.

Description

Replace first occurrence of a matched pattern in a string.

Usage

str_replace(string, pattern, replacement)

Arguments

string
input character vector
pattern
pattern to look for, as defined by a POSIX regular expression. See the ``Extended Regular Expressions'' section of regex for details.
replacement
replacement string. References of the form <1>, <2> will be replaced with the contents of the respective matched group (created by ()) within the pattern. fruits <- c("one apple", "two pears", "th

Value

  • character vector.

Details

Vectorised over string, pattern and replacement. Shorter arguments will be expanded to length of longest.

See Also

sub which this function wraps, str_replace_all to replace all matches