Skip to content
Legacy docs for Tenzir v5.x. For the latest Tenzir v6 series, visit docs.tenzir.com. Migrating from v5? Read the Tenzir v6 migration guide.

Replaces characters within a string.

replace(x:string, pattern:string, replacement:string, [max=int]) -> string

The replace function returns a new string where occurrences of pattern in x are replaced with replacement, up to max times. If max is omitted, all occurrences are replaced.

The subject to replace the action on.

The pattern to replace in x.

The replacement value for pattern.

The maximum number of replacements to perform.

If the option is not set, all occurrences are replaced.

from {x: "hello".replace("l", "r")}
{x: "herro"}
from {x: "hello".replace("l", "r", max=1)}
{x: "herlo"}

Last updated: