MySQL Tutorial/String Functions/REGEXP
expr REGEXP pat, expr RLIKE pat: Performs a pattern match of expr against pat
Returns 1 if expr matches pat; otherwise it returns 0.
If either expr or pat is NULL, the result is NULL.
REGEXP is not case sensitive, except when used with binary strings.
RLIKE is a synonym for REGEXP.
<source lang="sql">
mysql> mysql> mysql> SELECT "ABCDEF" REGEXP "A%C%%"; +-------------------------+ | "ABCDEF" REGEXP "A%C%%" | +-------------------------+ | 0 | +-------------------------+ 1 row in set (0.00 sec) mysql> SELECT "ABCDE" REGEXP ".*"; +---------------------+ | "ABCDE" REGEXP ".*" | +---------------------+ | 1 | +---------------------+ 1 row in set (0.00 sec) mysql> SELECT "new*\n*line" REGEXP "new\\*.\\*line"; +---------------------------------------+ | "new*\n*line" REGEXP "new\\*.\\*line" | +---------------------------------------+ | 1 | +---------------------------------------+ 1 row in set (0.00 sec) mysql></source>
SELECT "a" REGEXP "A", "a" REGEXP BINARY "A";
<source lang="sql">
mysql> mysql> SELECT "a" REGEXP "^[a-d]"; +---------------------+ | "a" REGEXP "^[a-d]" | +---------------------+ | 1 | +---------------------+ 1 row in set (0.00 sec) mysql></source>