Returns the starting position of the first instance of needle in haystack. Returns null if needle is not in haystack.

By default, this function counts from the beginning of the string, but you can specify a starting position.

Always counts in the natural direction of the advertiser’s locale. For example, if the advertiser’s language is English, this function counts from left to right.


search(needle, haystack[, starting-position])

needle and haystack can be any of the following:

  • A String constant, such as "GDN".
  • A Search Ads 360 variable that is a String, such as Keyword, Campaign, Engine_status, and so on.
  • An expression or formula column that returns a String.

starting-position is an optional positive integer that indicates where to start searching in haystack.
A value of 1 searches from the beginning of haystack (this is the same as the default behavior). A value of 4 starts searching from the 4th character.

Case insensitive

Text searches are case insensitive.

Empty character

If you include an expression or formula column in this function, the expression or formula column could evaluate to an empty string.

Be aware that searching for an empty string always returns 1. That is, search("", "GDN") evaluates to 1.


  • [search("cow","cowabunga")] returns 1.

  • [search("abunga","cowabunga")] returns 4.

  • [search("a","cowabunga")] returns 4, which is the location of the first a.

  • [search("a","cowabunga", 5)] returns 9, which is the location of the first a that occurs if you start counting from the 5th character.
    That is, search("a","cowabunga", 5) starts searching cowabunga from the 5th character, which is b. The function finds an a in position 9 of cowabunga.

Was this helpful?
How can we improve it?