regexp operator

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 10.0 and above

Returns true if str matches regex. regexp is a synonym for rlike operator.

Syntax

str [NOT] regexp regex

Arguments

  • str: A STRING expression to be matched.

  • regex: A STRING expression with a matching pattern.

Returns

A BOOLEAN.

The regex string must be a Java regular expression. String literals are unescaped. For example, to match '\abc', a regular expression for regex can be '^\\abc$'.

str NOT regexp ... is equivalent to NOT(str regexp ...).

Examples

> SELECT '%SystemDrive%\\Users\\John' regexp '%SystemDrive%\\\\Users.*';
true