replace

string

Replaces all occurrences of a substring with another string

Syntax

replace(string, old, new)

Parameters

string (string)

The string to search in

old (string)

The substring to find

new (string)

The replacement string

Returns

string

String with all occurrences replaced

Examples

Input:
replace("hello world", "world", "there")
Output:
"hello there"
Input:
replace("foo bar foo", "foo", "baz")
Output:
"baz bar baz"
Input:
"test  data" | replace("  ", " ")
Output:
"test data"

The replace() function replaces all occurrences of a specified substring with a new string. This is useful for data cleaning and text transformation.

Usage

Use replace() when you need to substitute text patterns, clean data by removing or replacing unwanted characters, or normalize string formats.

Related Functions