Regular Expressions (regex) are a powerful tool for defining complex queries.
here is a simple information that ignores some of the detailed information.
A regular expression defines a rule for a string. The simplest regular expression does not contain any reserved words. For example, the regular expression Hello is only matched to the string "Hello".
Regular expressions use some special structure, so it can match more strings. For example, regular expression Hello|word can match both the string "Hello" and the string "word". To give a more complicated example, the regular expression b[an]*s can match the string "Bananas", "Baaaaas", "Bs", and any other string that begins with B with the end of S, and the middle can include any combination of a and any n.
You can use the following reserved words in a regular expression
^
matches a string that starts with the following string
This is a more comprehensive approach that enables the functionality of several reserved words in the previous
A *
can be written as a{0,}
+
can be written as A{1,}
a?
can be written a{0,1}
only one integer parameter I in {}, which indicates that the character can only appear I; within {} There is an integer parameter I, followed by a ",", which indicates that the character can appear I or I, and that there is only one integer parameter in {}, followed by a ",", and then an integer parameter J, Indicates that the character can only appear more than I, J times below (including I and J times). The integer argument must be greater than or equal to 0, and less than or equal to Re_dup_max (default is 255). If there are two parameters, the second must be greater than or equal to the first
[A-DX]
matches "A", "B", "C", "D" or "X"
[^A-DX]
matches any character except "A", "B", "C", "D", "X". "[", "]" must be in pairs using
represents the order of the comparison elements. The order of characters within parentheses is unique. But the parentheses can contain wildcards, so he can match more characters. For example: Regular expressions [[. Ch.]] *c matches the first five characters of the CHCHCC.
[=character_class=]
represents an equal class that can replace other equal elements in a class, including itself. For example, if O and (+) are members of an equal class, then [[=o=]], [[= (+] =]] and [O (+)] are completely equivalent.
[: Character_class:]
in parentheses, in [: And:] The middle is the name of the character class, which can represent all characters belonging to this class.
The names of the character classes are: alnum, digit, punct, alpha, graph, space, blank, lower, upper, cntrl, print, and Xdigit
an empty string that matches the beginning and end of a word, and neither the beginning nor the end of the word is a character contained in Alnum nor an underscore.
mysql> Select "A word a" REGEXP "[[::]]"; -> 1 (matching)
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.