REPLACE

REPLACE replaces a segment of a string with another string.

Function category: Text

Syntax

REPLACE(arg1, arg2, arg3, arg4)

Arguments

Description

arg1

String to be segmented.

arg2

Position in the string at which to begin slicing.

arg3

Number of characters to slice from the string.

arg4

String to replace the substring delineated by arg2 and arg3.

arg2 is inclusive, meaning the character at the specified position will be included in the segment.

Example

Let's say we're given a response with an id value.

{
"data":{
"ids":{
"id_1": "1anb4amca051"
}
}
}

If we want to replace the first four digits of the id with our another string, use the following function.

# Replace specified digits with a strong
REPLACE(data.ids.id_1, 1, 4, "custom-id-")
‚Äč
# Returns "custom-id-4amca051"