Learn R Programming

pystr (version 2.0.0)

pystr_replace: Replace substrings within a string.

Description

Return a copy of the string with all occurrences of substring old replaced by new.

Usage

pystr_replace(str, old, new, count = nchar(str) + 2)

Arguments

str
A character vector.
old
A character vector.
new
A character vector.
count
A numeric vector.

Value

A character vector.

Details

If the optional argument count is given, only the first count occurrences are replaced.

References

https://docs.python.org/3/library/stdtypes.html#str.replace

Examples

Run this code
pystr_replace("123123123", "2", "two")
pystr_replace("123123123", "2", "two", 2)

Run the code above in your browser using DataLab