Learn R Programming

strs (version 0.1.0)

strs_replace: Replace substring in a string

Description

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)

Value

A character vector of the same length as string, with substring

replaced by 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.

See Also

Examples

Run this code
strs_replace("hello world", "world", "there")
strs_replace("banana", "na", "mo")

Run the code above in your browser using DataLab