REGEXP_EXTRACT_NTH

Syntax

REGEXP_EXTRACT_NTH( string, pattern, match_index )

Description

Returns a substring string that matches the regular expression pattern pattern starting from the specified index.

Argument types:

  • stringString
  • patternString
  • match_indexInteger

Return type: String

Note

Only constant values are accepted for the arguments (pattern).

Note

See the documentation of the data source to clarify the regular expression syntax. For example, ClickHouse uses the RE2 syntax to compose regular expressions.

Example

REGEXP_EXTRACT_NTH("RU 912 EN 873", "[A-Z]+\s+(\d+)", 2) = "873"

Data source support

ClickHouse 21.8, MySQL 8.0.12, Oracle Database 12c (12.1), PostgreSQL 9.3.