Events
Mar 31, 11 PM - Apr 2, 11 PM
The ultimate Microsoft Fabric, Power BI, SQL, and AI community-led event. March 31 to April 2, 2025.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
regexp_substr
functionApplies to: Databricks SQL Databricks Runtime 11.3 LTS and above
Returns the first substring in str
that matches regexp
.
regexp_substr( str, regexp )
str
: A STRING
expression to be matched.regexp
: A STRING
expression with a pattern.A STRING
.
The regexp
string must be a Java regular expression.
String literals are unescaped. For example, to match '\abc'
, a regular expression for regexp
can be '^\\abc$'
.
In case of a malformed regexp
the function returns an INVALID_PARAMETER_VALUE error.
If either argument is NULL
or the pattern is not found, the result is NULL
.
> SELECT regexp_substr('Steven Jones and Stephen Smith are the best players', 'Ste(v|ph)en');
Steven
> SELECT regexp_substr('Mary had a little lamb', 'Ste(v|ph)en');
NULL
> SELECT regexp_substr(NULL, 'Ste(v|ph)en');
NULL
> SELECT regexp_substr('Mary had a little lamb', NULL);
NULL
Events
Mar 31, 11 PM - Apr 2, 11 PM
The ultimate Microsoft Fabric, Power BI, SQL, and AI community-led event. March 31 to April 2, 2025.
Register today