跳到主要内容

RLIKE

声明

str RLIKE pat

说明

字符串是否匹配正则表达式。如果字符串 str 与指定的正则表达式匹配,则返回 1,否则返回 0。如果字符串 str 或者 pat 其中任一个是 NULL,返回值是 NULL

该函数是 REGEXP() 的同义词。

示例

SELECT 'hello world!' RLIKE '^hello','hello world!' RLIKE '^hello$';
+-------------------------------+--------------------------------+
| 'hello world!' RLIKE '^hello' | 'hello world!' RLIKE '^hello$' |
+-------------------------------+--------------------------------+
| 1 | 0 |
+-------------------------------+--------------------------------+
1 row in set (0.001 sec)