Regular expressions are a powerful way to specify patterns for complex searches.
MySQL is implemented with Henry Spencer's regular expression, which targets POSIX 1003.2.
Match a string that starts with a number
SELECT * from ' Gms_customer ' where Mobile REGEXP ' ^[0-9] ';
Matches the string containing--a bit similar to like%-%
Special characters generally use \\-\ \. \ \ is the leading, the role of the transfer
SELECT * from Gms_customer where mobile REGEXP ' \\-';
Match a string ending with a number
SELECT * from Gms_customer where mobile REGEXP ' [0-9]$ ';
Match None or empty a bit like name = ' None ' or name= '
SELECT * from Gms_customer where name REGEXP ' None | ';
Match a string containing 2 or 6 or 3
SELECT * from Gms_customer where customer_id REGEXP ' [263] ';
Match characters:
[: a;num:] Any letter and number (same as [a-za-z0-9])
[: Alpha:] Any character (same as [a-za-z])
[: Blank:] spaces and tabulation (same as [\\t])
[: Cntrl:] ASCII control characters (ASCII 0 to 31 and 127)
[:d igit:] Any number (same as [0-9])
[: Graph:] Same as ["Print:], but not including spaces
[: Lower:] Any lowercase line (same as [A-z])
[:p rint:] any printable character
[:p UNCT:] Neither [: alnum:] Nor any of the characters in [: Cntrl:]
[Space:] Any white space character, including spaces (same as [\\f\\n\\t\\r\\v])
[: Upper:] Any size letter (same as [A-z])
[: xdigit:] any hexadecimal digit (same as [a-fa-f0-9])
Locator:
^ Beginning of the text
The end of the $ text
[[: <:]] The beginning of the word
[[:]: The end of the word
The basic knowledge of regular expressions can be consulted: regular Expressions 30-minute introductory tutorial
Http://deerchao.net/tutorials/regex/regex-1.htm
This article is from the "Chase Dream" blog, please be sure to keep this source http://dreameng.blog.51cto.com/1187899/1588101
MySQL Simple regular expression query