The regular expression uses the RE module
Import re to begin calling the regular expression.
The usual regular has the following characters:. ^ $ * + ? {} [] \ | ()
. matches any character other than \ n, and can match line breaks in Dotall mode. ^ matches the beginning of the string, matching the beginning of each line in multiline mode. [^] matches content that does not contain certain strings. $ matches the content that ends with a string. * matches 0 or more arbitrary characters. + matches 1 or more arbitrary characters. matches 0 or 1 arbitrary characters. {} matching content can be similar to * +  , like: {0,} == * {1,} == + {0,1} == ? {m,n} matches the previous character M~n times. {m} matches the previous character m times. [] character set, the corresponding position can be in the character setAny character in a character set can be listed as a group, or it can be given a range, such as [ABC] or [A-c]. the first character, if it is ^, is reversed, such as [^abc] means other characters that are not ABC. \ the escape character so that the latter character becomes the original meaning. | represents an arbitrary match between the left and right expressions. ( ) the enclosed expression as a grouping, starting from the left side of the expression to encounter each grouping of the opening parenthesis ' (', number +1. Another grouping expression as a whole, can be followed by a number of words. The | in an expression is only valid in that group. (? P<name>, ...) Group, specify an additional alias in addition to the original number. (? P<ID>ABC) {2}
\d: Matches any decimal number equal to [0-9]
\d: Matches any non-numeric character equivalent to [0-9]
\s: Matches any white space character, equivalent to [\t\n\r\f\v]
\s: Matches any non-whitespace character equivalent to [^\t\n\r\f\v]
\w: Matches any alphanumeric character, equivalent to [a-za-z0-9]
\w: Matches any non-alphanumeric character equivalent to [^a-za-z0-9]
This article is from the "less stubborn" blog, please be sure to keep this source http://xushaojie.blog.51cto.com/6205370/1789406
Python learning regular expression re module