REGEXP_LIKE
Syntax
REGEXP_LIKE(expr, pat[, match_type])
Description
REGEXP_LIKE returns 1 if the string expr matches the pattern specified by the regular expression pat, and 0 otherwise. If expr or pat is NULL, it returns NULL.
The match_type parameter specifies the matching mode. Valid values are:
-
c: case-sensitive matching. -
i: case-insensitive matching. -
m: recognizes newline characters in the string. By default, only newline characters at the beginning and end of the string are matched. -
n: the dot.matches only newline characters (\n). By default,.matches any single character except a newline character (\n). -
u: matches only Unix-style line endings. Only newline characters (\n) are recognized as line endings by.and$.
Examples
SELECT REGEXP_LIKE('OceanBase', 'OCEANBASE');
+---------------------------------------+
| REGEXP_LIKE('OceanBase', 'OCEANBASE') |
+---------------------------------------+
| 1 |
+---------------------------------------+
1 row in set (0.001 sec)
SELECT REGEXP_LIKE('OceanBase', 'OCEANBASE','c');
+-------------------------------------------+
| REGEXP_LIKE('OceanBase', 'OCEANBASE','c') |
+-------------------------------------------+
| 0 |
+-------------------------------------------+
1 row in set (0.001 sec)
SELECT REGEXP_LIKE('Ocean\nBase', 'OCEAN.BASE');
+------------------------------------------+
| REGEXP_LIKE('Ocean\nBase', 'OCEAN.BASE') |
+------------------------------------------+
| 0 |
+------------------------------------------+
1 row in set (0.000 sec)
SELECT REGEXP_LIKE('Ocean\nBase', 'OCEAN.BASE','n');
+----------------------------------------------+
| REGEXP_LIKE('Ocean\nBase', 'OCEAN.BASE','n') |
+----------------------------------------------+
| 1 |
+----------------------------------------------+
1 row in set (0.000 sec)