REGEXEXTRACT

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

Function category: Text

Syntax

REGEXEXTRACT(arg1, arg2)

Arguments

Description

arg1

String to be searched.

arg2

Regex pattern to search.

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 bad condition."
}
}
}
}

If we know that the attribute description has a standard form and uses standardized terminology, we can do a search for a string using REGEXEXTRACT. In this example we search for the string functional using ".unctional".

# Search for the first occurance of a string
REGEXEXTRACT(data.mechanic_reports.vehicle_1.description, ".unctional")
# Returns functional
# The string ".unctional" was found

In this example we search for the string functional using ".uto".

# Search for the first occurance of a string
REGEXEXTRACT(data.mechanic_reports.vehicle_1.description, ".uto")
# Returns null
# The string ".uto" was not found