description |
---|
Extracts the first string in expression that matches the REGEXP expression and corresponds to the REGEX group index. |
- input: The expression to search for a matching string.
- regex: The Perl-compatible regular expression (PCRE) to match against.
- expr_group_index: A regular expression group number, defining which portion of the matching string will be returned.
Examples
{% code title="REGEXP_EXTRACT example" %}
SELECT REGEXP_EXTRACT('100-500', '(\d+)-(\d+)', 1)
-- EXPR$0
-- 100
{% endcode %}
{% code title="REGEXP_EXTRACT example" %}
SELECT REGEXP_EXTRACT('100-500', '(\d+)-(\d+)', 0)
-- EXPR$0
-- 100-500
{% endcode %}