MySQL Simple regular expression query

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.