Mega Code Archive

 
Categories / MySQL Tutorial / String Functions
 

Expr REGEXP pat, expr RLIKE 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. 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>