MySQL Regular Expression Search

Source: Internet
Author: User
Tags control characters uppercase letter

The Products table is as follows:



1. Basic character Matching



Using regular expressions and like, the regular expression is searched throughout the column, as long as the prod_name contains the characters that are searched, and if you do not use wildcards, then the prod_name is required to match the search characters exactly: that is, the following example needs to be used Like ' JetPack 1000 ' can be adapted to a search.



2 using or for a matching search, you can search for two conditions, or you can connect multiple conditions:



3 matches one of several characters://This means to say, match 1 ton or 2 ton or 3 ton



But it is wrong to write the following://This means matching 1 or 2 or 3 ton columns



4 range matching, [1-5] is actually [12345] shorthand, in addition [0-9],[3-9] are legal.



5 Match Special characters, match Special characters need to use \ \



6 Matching multiple instances

repeating element characters:

Metacharacters Description
* 0 or more matches
+ 1 or more matches
0 or 1 matches
N A specified number of matches
{N,} No less than a specified number of matches
{N,m} range of matching numbers

The search condition below means that there is a right parenthesis first, then there should be a number, then a space, then a sticks, and finally 0 or 1 left brackets, the meaning of the question mark is as shown in the table above



7 character types for ease of work, a predefined character set can be used, with the following character set:

Class Description
[: Alpha:] Any character
[: Blank:] Spaces and Tabs
[: Cntrl:] ASCII control characters (from ASCII0 to 31 and 127)
[:d Igit:] arbitrary number with [0-9]
[: Graph:] Any printable character, but not spaces
[: Lower:] Any lowercase letter
[:p rint:] any printable character
[:p UNCT:] No [: Alnum:] does not have any characters in [: Cntrl:]
[: Space:] Any white space character, including spaces
[: Upper:] Any uppercase letter
[: Alnum:] Any letters and numbers

Next, search the table for the name of 4 consecutive digits in the prod_name: where [:d igit:] denotes any number, {4} indicates that the number needs to occur 4 times:



8 Locator Search in a specific location

Metacharacters Description
^ Text start
$ End of text
[[: <:]] The beginning of the word
[[:;:]] The end of the word

The following statement is looked up with a number or. The beginning of the Prod_name




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.