Regular expression common matching rules

\w

Match letters, numbers and underscores

\W

Match characters that are not letters, numbers, and underscores

\s

Matches any blank character, which is equivalent to [\\t\\n\\r\\f]

\S

Match any non-blank character

\d

Matches any number, which is equivalent to [0-9]

\D

Match any non-digit character

\A

Match the beginning of the string

\Z

Match the end of the string, if there is a newline, only match to the ending string before the newline

\z

Match the end of the string, if there is a newline, it will also match the newline

\G

Match the position where the last match was completed

\n

Matches a newline character

\t

Matches a tab

^

Match the beginning of a line of string

$

Match the end of a line

.

Match any character, except for the newline character, when the  re.DOTALL tag is specified, it can match any character including the newline character

[...]

Used to represent a group of characters, listed separately, such as  [amk] matching  a, m or k

[^...]

Not  [] characters, such as  [^abc] addition to matching  a, b, c characters other than

*

Match 0 or more expressions

+

Match 1 or more expressions

?

Match 0 or 1 fragment defined by the previous regular expression, non-greedy way

{n}

Exactly match the  n previous expression

{n, m}

Matching  n the  m time segment defined by the preceding regular expression greedy manner

a|b

Match  a or b

( )

Matches the expression in parentheses, also represents a group

Guess you like

Origin blog.csdn.net/guo15890025019/article/details/114888769