- Description: Extracts a substring that matches a regex pattern.
- Purpose: Retrieving specific patterns from strings.
- Syntax:
REGEXP_SUBSTR(string, pattern, [start_position], [match_occurrence])
- Parameters:
string
: The source string.
pattern
: The regex pattern to match.
start_position
: Where to start searching.
match_occurrence
: Which occurrence to return.
- Returns: The matching substring or
NULL
if not found.
- Example:
REGEXP_SUBSTR('abc123', '[0-9]+')
returns '123'
.
- Notes: Powerful for extracting formatted data.
- Use Case: Parsing codes or identifiers from strings.
Leave a Reply