This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
SUBSTITUTE
Dan Gorman edited this page Nov 29, 2018
·
3 revisions
SUBSTITUTE
replaces a segment of a string with another string.
SUBSTITUTE(arg1, arg2, arg3, arg4)
-
arg1
is a string or block of text to be searched -
arg2
is the search string -
arg3
is the string to replace the search string with -
arg4
is occurrence number
Let's say we're given a response with some ids:
{
"data":{
"ids":{
"id_1": "1identification_number=1anb4amca051",
"id_2": "22zlb4ftba492"
}
}
}
If we want to substitute "id=" for "identification_number=" in the first id, we can use SUBSTITUTE
:
SUBSTITUTE(data.ids.id_1, "1identification_number=" , "id=")
This will return "id=1anb4amca051"
If we want to use the optional fourth argument, which specifies the occurrence to substitute, we can do so. In the case below we only want to remove the first 2 and set it equal to "id=":
SUBSTITUTE(data.ids.id_2, "2", "id=", 1) => "id=2zlb4ftba492"
See REPLACE
for a similar string operation that can be done based on character indexes.