Skip to main content
REGEX_EXTRACT

Extracts text that matches a regular expression pattern

Updated over a year ago

Description

The REGEX_EXTRACT() function is used to extract specific text from a given text string that matches a regular expression pattern. It's a powerful tool for text parsing and data extraction based on complex patterns.

Syntax

REGEX_EXTRACT(text, “pattern", [offset])

Output

text

Variables

  1. text: The input text string from which you want to extract text.

  2. pattern: The regular expression pattern used to identify the text to be extracted.

  3. offset: (Optional) An offset (number greater than 0) that specifies which match to extract when there are multiple matches in the text.

Example

REGEX_EXTRACT(`Original Text`,"[A-Z]+\d+",1)

ID

Original Text

REGEX_EXTRACT

1

Product ID: ABC123, Price: $45.99

ABC123

2

Order: ORD98765, Date: 2023-09-15

ORD98765

3

Phone: (555) 555-5555, Email: [email protected]

Did this answer your question?