Text & patterns
Scalar
regexp_extract()
If string contains the regex pattern, returns the capturing group specified by optional parameter group; otherwise, returns the empty string. The group must be a constant value. If no group is given, it defaults to 0. A set of optional regex options can be set.
Arguments & returns
5 overloadsregexp_extract(string, regex)
Scalar
| Overload link | string | regex |
Returns |
|---|---|---|---|
| #01 | VARCHAR | VARCHAR |
VARCHAR |
regexp_extract(string, regex, group)
Scalar
| Overload link | string | regex | group |
Returns |
|---|---|---|---|---|
| #02 | VARCHAR | VARCHAR | INTEGER |
VARCHAR |
regexp_extract(string, regex, name_list)
Scalar
If string contains the regex pattern, returns the capturing groups as a struct with corresponding names from name_list; otherwise, returns a struct with the same keys and empty strings as values. A set of optional regex options can be set.
| Overload link | string | regex | name_list |
Returns |
|---|---|---|---|---|
| #03 | VARCHAR | VARCHAR | VARCHAR[] |
VARCHAR |
regexp_extract(string, regex, group, options)
Scalar
| Overload link | string | regex | group | options |
Returns |
|---|---|---|---|---|---|
| #04 | VARCHAR | VARCHAR | INTEGER | VARCHAR |
VARCHAR |
regexp_extract(string, regex, name_list, options)
Scalar
| Overload link | string | regex | name_list | options |
Returns |
|---|---|---|---|---|---|
| #05 | VARCHAR | VARCHAR | VARCHAR[] | VARCHAR |
VARCHAR |
Example
4 more ↓Haybarn WASM 1.5.5-rc3 · In your browser
Engine example · Run to view results.
More examples
Haybarn WASM 1.5.5-rc3 · In your browser
Engine example · Run to view results.
Haybarn WASM 1.5.5-rc3 · In your browser
Engine example · Run to view results.
Haybarn WASM 1.5.5-rc3 · In your browser
Engine example · Run to view results.
Haybarn WASM 1.5.5-rc3 · In your browser
Engine example · Run to view results.
In other engines
Amazon Redshiftregexp_substr()
SELECT REGEXP_SUBSTR(abc, 'pattern(group)', 2) FROM table
SELECT REGEXP_EXTRACT(SUBSTRING(abc, 2), 'pattern(group)') FROM "table"
Apache Hiveregexp_extract()
REGEXP_EXTRACT('abc', '(a)(b)(c)')
REGEXP_EXTRACT('abc', '(a)(b)(c)', 1)
Snowflakeregexp_substr()
REGEXP_SUBSTR(subject, pattern)
REGEXP_EXTRACT(subject, pattern)