REGEX_EXTRACT

Extracts text that matches a regular expression pattern

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])

  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

Table

ID
Original Text

1

Product ID: ABC123, Price: $45.99

2

Order: ORD98765, Date: 2023-09-15

3

Phone: (555) 555-5555, Email: john@example.com

Function

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

Results

REGEX_EXTRACT (text)

ABC123

ORD98765

(null)

Last updated