Zhang Xiaoxiang Regular expression Video learning notes.
1. What is a regular expression
Regular expressions are translated by the English phrase "regular expression", which can be understood as a language that blurs the text.
Using some special characters (meta-characters) to express text should have some characteristics.
2. Definition of meta-characters
A character with a special meaning in a regular expression that describes the character of the text.
For example, "?" Indicates that the preceding characters are optional, such as ABC? The description character "C" is optional and can match ABC and AB.
3. Sub-match
The portion of the regular expression enclosed in parentheses is called a sub-match, and the sub-match can also be referenced again.
The \1 can match the first sub-match, and \2 can match the second sub-match.
For example, 2 consecutive arbitrary numbers can be represented by (\d) \1, and any 5 consecutive digits can be matched with (\d) \1{4}.
1221,3553 can use (\d) (\d) \2\1 to represent a matching relationship.
The basis of regular expressions (i)