SEARCH

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

Function category: Text

Syntax

SEARCH(arg1, arg2, [arg3])

Arguments

Description

arg1

String that is searched.

arg2

Block of text to be search.

arg3

Optional. Place to begin searching for the string.

Examples

Let's say we're given a response with the following vehicle information:

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

Example 1: Find location of a string in a block of text

If we know that the value for the description key has a standard structure and uses standardized terminology, we can using SEARCH to find the string "bad" using this function.

# Search for the position of a string in an object
SEARCH("bad", data.mechanic_reports.vehicle_1.description)
# Returns 41
# This is the position in the string
# at which arg1 first appears

Example 2: Find location after a starting point

We can also add the third, optional argument, to search for a specific starting point using this function.

# Search for starting point of of a string in an object
SEARCH("bad", data.mechanic_reports.vehicle_1.description, 41)
# Returns 66