One, match meta-characters
The use of meta-characters can be easily manipulated to write regular expressions more convenient
Common Meta characters:
. It matches any character except the newline character in alternate mode (re. Dotall) It can even match a newline ^ to match the beginning of the line. Unless you set the MULTILINE flag, it only matches the beginning of the string. $ matches the end of the line, and the end of the line is defined as either the end of the string or any position following a newline character. * Repeat 0 or n times + repeat 1 or n times? Repeat 0 or 1 times {} The qualifier means at least m duplicates, up to n repetitions [] they are often used to specify a character category, so-called character categories are the character set you want to match. The backslash can be appended with different characters utilises to represent different special meanings. It can also be used to cancel all meta-characters so you can match them in the pattern | An option, or an "or" operator. () group \d matches any decimal number; it is equivalent to class [0-9]. \d matches any non-numeric character; it is equivalent to class [^0-9]. \s matches any whitespace character; it is equivalent to class [\t\n\r\f\v]. \s matches any non-whitespace character; it is equivalent to class [^\t\n\r\f\v]. \w matches any alphanumeric character; it is equivalent to class [a-za-z0-9_]. \w matches any non-alphanumeric character; it is equivalent to class [^a-za-z0-9_]. \a matches only the first string. When not in MULTILINE mode, \a and ^ are actually the same. However, they are different in the MULTILINE mode; \a just matches the first string, and ^ can also match any position in the string after the line break. \z only matches the end of the string. \b Word boundaries. This is a 0-wide qualifier (Zero-width assertions) that matches only the first and final words of a word. A word is defined as an alphanumeric sequence, so the ending is marked with a white or non-alphanumeric character. \b Another 0-wide qualifier (zero-width assertions), which is exactly the same as \b, and matches only when the current position is not at the word boundary. Second, the actual application of the sequence of matching is just beginning to learn when the feeling is very confusing, but after several times found to match up with the normal reading, from left to right 1) match the first character is not finished to be continued ....
Python Regular Expression Summary