Mysql Regular Expression regexp Usage Details

Source: Internet
Author: User
Regexp ^ ??????????????????????? Match the starting part of the string $ ??????????????????????? Matches the end part of the string .???????????????????????? Match any character (including carriage return and new line *????????????????????? Match any sequence of 0 or multiple characters a + ????????????????????? Horse

Regexp ^ ??????????????? ???????? Match the starting part of the string $ ??????????????? ???????? Matches the end part of the string .???????????????? ???????? Match any character (including carriage return and new line *????????????? ???????? Match any sequence of 0 or multiple a characters ????????????? ???????? Horse

Regexp

^ ??????????????? ???????? Match the start part of the string

$ ??????????????? ???????? End part of the matched string

.???????????????? ???????? Match any character (including carriage return and new line)

A *????????????? ???????? Matches any sequence of 0 or multiple a characters

A + ????????????? ???????? Any sequence that matches one or more a characters

A ?????????????? ???????? Match 0 or 1 a character

De | abc ?????????????? Matching sequence de or abc

(Abc )*??????????????? Matches 0 or multiple adc instances of a sequence.

{N}, {m, n }??????? The {n} or {m, n} symbol provides a more common way to write regular expressions and can match many of the aforementioned atoms (or "parts") of the pattern "). Both m and n are integers.

A *????????????? Can be written as a {0 ,}

A + ????????????? Can be written as a {1 ,}

A ?????????????? It can be written as a {0, 1}

[A-dX] ??? Matches any character that is a, B, c, d, or X. The '-' character between two other characters forms a range.

[^ A-dX] ??? Match any character that is not a, B, c, d, or X. The character '^' in front of it indicates no.

[. Characters.]? In a bracket expression (using [and]), match the character sequence used for element verification. The character is a single character or a new line or other character names.

Mysql> SELECT '~ 'Regexp' [[...] ';?????????????????????????????????????? ???????????????? -> 1

Mysql> SELECT '~ 'Regexp' [[. tilde.] ';? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -> 1

[= Character_class =]

In the brackets (using [and]), [= character_class =] indicates the same type. It matches all characters with the same value, including its own,

[[= A =] ??? Equivalent to [a (+)], [a +], [a {1,}]

[: Character_class:]

In a bracket expression (using [and]), [: character_class:] indicates the character class that matches all characters in the term class.

The standard class name is:

Alnum ?????? Character

Alpha ??????? Character

Blank ???????? White space characters

Cntrl ???????? Control characters

Digit ????????? Numeric characters

Graph ??????? Graphical characters

Lower ??????? Lowercase characters

Print? ? ? ? ? Graphical or space characters

Punct ??????? Punctuation

Space ??????? Space, tab, new line, and carriage return

Upper ??????? Uppercase characters

Xdigit ??????? Hexadecimal numeric characters

[[: <:], [[:>:]

These tags indicate word boundaries. They match the start and end of word respectively. Word is a series of character characters, with no character at the front and back. The character is a letter, digit, or underscore (_) in the alnum class (_).

Mysql> select 'fang shan zi 'regexp '[[: <:] shan [[:]'; ??? -> 1

Mysql> select 'fang shan zi 'regexp '[[: <:] fang [[:]'; ??? -> 1

Mysql> select 'fang shans zi 'regexp '[[: <:] shan [[:]'; ??? -> 0

The regular expression uses special characters and should be preceded by two backslash '\' characters.

Mysql> SELECT '1 + 2' REGEXP '1 + 2 ′;?????????????????????? -> 0

Mysql> SELECT '1 + 2' REGEXP '1 \ + 2 ′;????????????????????? -> 0

Mysql> SELECT '1 + 2' REGEXP '1 \ + 2 ′;???????????????????? -> 1

Original article address: mysql Regular Expression regexp Usage Details, thanks to the original author for sharing.

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.