Skip to main content
Version: 1.0.0

Expr.str.replace_all

def replace_all(pattern: str | Expr, value: str | Expr, literal: bool = False) -> Expr

Categories: string

Replace the all occurences of a pattern with the given string.

Parameters

parameter
pattern

The pattern to replace.

parameter
value

The value to replace the pattern with.

parameter
literal

Take the pattern as a literal string (not a regex).

Examples

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.replace("b", "X").alias("replace"))
>>>
┌───────────┬─────────────┐
│ a ┆ replace_all │
------
strstr
╞═══════════╪═════════════╡
│ a bAb c d ┆ a XAX c d │
│ bCbb c d ┆ XCXX c d │
│ bb ┆ XX │
│ b ┆ X │
│ a ┆ a │
│ null ┆ null │
└───────────┴─────────────┘