Substitutes all instances of needle in haystack with replacement. Specify occurrence to indicate which instance of needle to replace.
Always counts in the natural direction of the advertiser’s locale. For example, if the advertiser’s language is English, this function substitutes from left to right.
substitute(haystack, needle, replacement[ ,occurrence])
haystack, needle, and replacement can be any of the following:
- A String constant, such as "GDN".
- A Search Ads 360 variable that is a String, such as
Engine_status, and so on.
- An expression or formula column that returns a String.
occurrence can be any of the following:
- A positive constant, such as 1.
- A Search Ads 360 variable that is a positive number.
- An expression or formula column that returns a positive number.
Counting starts from 1.
[substitute("the quick brown fox jumps over the lazy dog", "the", "a", 2)]returns “the quick brown fox jumps over a lazy dog”.
If keyword contains “summer shoes”, substitute “sandals” for “shoes”:
[substitute(keyword, "summer shoes", "summer sandals")]