Skip to content

replace

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"}

replace_regex