Using regular expression queries in MySQL

Source: Internet
Author: User
Tags mysql query

The regular expression function is really powerful, the day dedicated to learning, here is temporarily used in MySQL query.

Regular expressions are powerful and flexible and can be applied to very complex queries.

Options Description (auto plus match word) Example Example of matching values
^ Text Start character ' ^b ' matches a string beginning with the letter B Book, big, banana, bike
$ Text End character ' st$ ' matches a string ending with St Test, resist, persist
. Any single character ' b.t ' matches any one character between B and t Bit, bat, but, bite
* 0 or more characters in front of it ' F*n ' match character n preceded by any n characters F FN, fan, FAAN, ABCN
+ The preceding character is one or more times The ' ba+ ' match starts with a b followed by at least one a BA, bay, Bare, battle
< strings > Text containing the specified string ' FA ' Fan, AFA, Faad
[Character Set] Any of the characters in a character set ' [XZ] ' matches x or Z Dizzy, Zebra, X-ray, extra
[^] Any characters that are not in parentheses ' [^ABC] ' matches any string that does not contain a, B, or C Desk, Fox, F8ke
string {n} The preceding string is at least n times B{2} matches 2 or more B BBB, BBBB, BBBBBB
string {n,m} The preceding string is at least n times, up to M times b{2,4} matches a minimum of 2, up to 4 b BB, BBB, BBBB

where field name REGEXP mode;

Using regular expression queries in MySQL

Related Article

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.