REGEXEXTRACT

Description

The REGEXEXTRACT function extracts the first part of a text value that matches a regular expression.

Usage

REGEXEXTRACT(text, regular_expression)

Arguments

Argument Type Required Description
text Text Yes The input text
regular_expression Text Yes The regular expression for which to search

Result

  • The part of text that matches the given regular_expression

Examples

Regular expressions are a versatile tool for matching text. For example, if you might want to extract the area code in order to summarize the number of participants by city.

In the US, phone numbers look like (570) 724-3053, where 570 is the so-called area code. If we have a text field in a form called PHONE_NUMBER, then we could add a calculated field for the area code using the formula:

REGEXEXTRACT(PHONE_NUMBER, "[0-9]{3}")

The formula above will match the first group of 3 digits in the PHONE_NUMBER field:

NAME PHONE_NUMBER AREA
Alex (570) 724-3053 570
Alexandria (202) 225-3965 202
Next item
REGEXMATCH