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])
text
: The input text string from which you want to extract text.pattern
: The regular expression pattern used to identify the text to be extracted.offset: (Optional) An offset (number greater than 0) that specifies which match to extract when there are multiple matches in the text.
Example
Table
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
ABC123
ORD98765
(null)
Last updated