strs_replace: Replace substring in a string

View source: R/replace.R

strs_replaceR Documentation

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)

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.

Value

A character vector of the same length as string, with substring replaced by replacement.

See Also

Python str.replace() documentation

Examples

strs_replace("hello world", "world", "there")
strs_replace("banana", "na", "mo")

strs documentation built on Sept. 11, 2024, 6:44 p.m.