polars.internals.series.StringNameSpace.replace

StringNameSpace.replace(pattern: str, value: str) polars.internals.series.Series

Replace first regex match with a string value.

Parameters
pattern

A valid regex pattern.

value

Substring to replace.

Examples

>>> s = pl.Series(["123abc", "abc456"])
>>> s.str.replace(r"abc", "ABC")
shape: (2,)
Series: '' [str]
[
        "123ABC"
        "abc456"
]