MySQL Beginner note Seven: Use regular expressions in MySQL! (Video serial number: primary _44)

Source: Internet
Author: User

Knowledge Point nine: using regular expressions in MySQL (44)

(1): REGEXP ' matching method ':

(2): Common matching method:

Pattern character

^

Matches the starting part of the character

$

Matches the part of the end of the string

.

Represents any of the characters in a string, including carriage returns and line breaks

[Character Set and]

Match character set and any one of the characters in

[^ Character Set and]

Match any one character except the character set

s1| s2| S3

Match any string in S1,S2,S3

*

Represents 0 and one or more of its preceding characters

+

Represents 1 or more characters in front of it

String{n}

String appears n times

string {m,n}

The string appears at least m times and appears at most n times

1 --^ matches the starting part of the character2 --querying users with a user name starting with T3 SELECT *  fromCms_userWHEREUsername REGEXP'^t';4 5 --$ matches the part of the end of the string6 7 SELECT *  fromCms_userWHEREUsername REGEXP'g$';8 9 Ten --. Represents any character One  A SELECT *  fromCms_userWHEREUsername REGEXP'.'; -  - SELECT *  fromCms_userWHEREUsername REGEXP'R.. G'; the  - SELECT *  fromCms_userWHEREUsername like 'R__g'; -  - --[Set] [LTO] +  - SELECT *  fromCms_userWHEREUsername REGEXP'[LTO]'; +  A --[^ charset] In addition to the contents of the character set at SELECT *  fromCms_userWHEREUsername REGEXP'[^lto]'; -  - SELECT *  fromCms_userWHEREUsername REGEXP'[^l]'; -  - INSERTCms_user (username,password,regtime,proid) - VALUES('lll','lll',138212349,2), in('TTT','lll',138212349,2), -('ooo','lll',138212349,2); to  + SELECT *  fromCms_userWHEREUsername REGEXP'[A-k]'; -  the SELECT *  fromCms_userWHEREUsername REGEXP'[^a-m]'; *  $ SELECT *  fromCms_userWHEREUsername REGEXP'Ng|qu';Panax Notoginseng  - SELECT *  fromCms_userWHEREUsername REGEXP'Ng|qu|te'; the  + SELECT *  fromCms_userWHEREUsername REGEXP'que*'; A  the  + SELECT *  fromCms_userWHEREUsername REGEXP't+'; -  $ SELECT *  fromCms_userWHEREUsername REGEXP'que+'; $  - SELECT *  fromCms_userWHEREUsername REGEXP'que{2}'; -  the SELECT *  fromCms_userWHEREUsername REGEXP'Que{3}'; - Wuyi SELECT *  fromCms_userWHEREUsername REGEXP'que{1,3}';
regular-expression testing

MySQL Beginner note Seven: Use regular expressions in MySQL! (Video serial number: primary _44)

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.