Returns true if a string contains a match for the specified regular expression pattern, or false otherwise.
Limits
Supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0 or later.
Syntax
BOOLEAN REGEXP(VARCHAR str, VARCHAR pattern)Parameters
| Parameter | Data type | Description |
|---|---|---|
str | VARCHAR | The string to search. |
pattern | VARCHAR | The regular expression pattern to match against. |
Usage notes
If
strorpatternisNULL, the function returnsNULL.If
patternis an invalid regular expression (for example, an unmatched parenthesis), the function returnsfalse.
Example
Test data (table T1)
| str1 (VARCHAR) | pattern1 (VARCHAR) |
|---|---|
| k1=v1;k2=v2 | k2\* |
| k1:v1|k2:v2 | k3 |
| NULL | k3 |
| k1:v1|k2:v2 | NULL |
| k1:v1|k2:v2 | ( |
Test statement
SELECT REGEXP(str1, pattern1) AS `result`
FROM T1;Test result
| result (BOOLEAN) |
|---|
| true |
| false |
| NULL |
| NULL |
| false |
Rows 3 and 4 return NULL because one of the inputs is NULL. Row 5 returns false because ( is not a valid regular expression pattern.