Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 1019 Bytes

File metadata and controls

33 lines (26 loc) · 1019 Bytes
description
Extracts the first string in expression that matches the REGEXP expression and corresponds to the REGEX group index.

REGEXP_EXTRACT

Syntax

REGEXP_EXTRACT(input string, regex string, expr_group_index integer) → string

  • 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 %}