Skip to content
Dan Gorman edited this page Nov 29, 2018 · 2 revisions

The SEARCH Function

Function Group: Text

SEARCH finds the first appearance of a string within a block of text.

Syntax

SEARCH(arg1, arg2, [arg3])

  • arg1 is a string to search for
  • arg2 is the string to be searched
  • arg3 is optional, and is the "starting" point for the string to search

Uses

Let's say we're given a response with some vehicle information that looks like this:

{  
   "data":{  
      "mechanic_reports":{  
         "vehicle_1":{  
            "description":"The car was still functional, but had a bad radiator, and was in bad condition."
         }
      }
   }
}

If we know that the description attribute is going to have a standard structure and used standardized terminology, we can do a search for, let's say, "bad":

SEARCH("bad", data.mechanic_reports.vehicle_1.description)

This would return 41 - which is the position in the string at which our arg1 first appears.

Other Examples

We can also add the third, optional argument, to search after a specific starting point, like this:

SEARCH("bad", data.mechanic_reports.vehicle_1.description, 41) => 66

Clone this wiki locally