dataengref migrate

Home / Oracle

Oracle REGEXP_SUBSTR in Snowflake, Databricks and BigQuery

Snowflake REGEXP_SUBSTR takes the same position, occurrence and group arguments as Oracle. BigQuery REGEXP_SUBSTR is a synonym of REGEXP_EXTRACT. Databricks regexp_substr returns the whole match only; use regexp_extract for a capture group.

Oracle function: REGEXP_SUBSTR(source, pattern [, position [, occurrence [, match_param [, subexpr]]]]) · Oracle docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeSame nameREGEXP_SUBSTR(subject, pattern [, position [, occurrence [, regex_parameters [, group_num]]]])Same argument order as Oracle.Snowflake docs
DatabricksSame nameregexp_substr(str, regexp)Two arguments only and the whole match. For a group use regexp_extract(str, regexp, idx).Databricks docs
BigQuerySame nameREGEXP_SUBSTR(value, regexp [, position [, occurrence]])Synonym of REGEXP_EXTRACT; with one capture group it returns the group.BigQuery docs

Behavior differences to check

Databricks

BigQuery

Examples

Domain from an email address

Oracle
SELECT REGEXP_SUBSTR(email, '@(.+)$', 1, 1, NULL, 1) AS domain FROM users;
Snowflake
SELECT REGEXP_SUBSTR(email, '@(.+)$', 1, 1, 'e', 1) AS domain FROM users;
Databricks
SELECT regexp_extract(email, '@(.+)$', 1) AS domain FROM users;
BigQuery
SELECT REGEXP_SUBSTR(email, r'@(.+)$') AS domain FROM users;

Other Oracle functions

Last checked: · Paste a whole query into the SQL checker to find every function that needs a change.