Special characters in Python regular expressions:
^ indicates that the matching character must be in the front
$ indicates that the matching character must be on the last side
* Match * preceding characters 0 or n times
+ match + previous characters 1 or n times
? The? The preceding character 0 or 1 times
. (decimal point) matches all characters except line break
(x) match x and record matching values
x|y match x or Y
{n} here n is a positive integer. Match the preceding n characters
{n,} here n is a positive integer. Matches at least n preceding characters
{n,m} here N and M are all positive integers. Matches at least N, up to M preceding characters
[XYZ] character list, which matches any one of the characters in the table, can be connected by character-indicating a range of characters, such as [A-z] for all lowercase letters
[b] matches a space
b matches the dividing line of a word, such as a space
B matches the non-dividing line of a word
re module matching rules (the third parameter of the Re.match function):
Re. IGNORECASE ignoring the case in the text
Re. Locale handles character set localization
Re. MULTILINE support for multi-line matching
Re. Dotall matches some special tags, such as using. Match \ n characters
Re. VERBOSE ignores whitespace or newline characters in regular expressions
Re. Unicode uses Unicode encoding
Here is an example of a matching mailbox
def isemail (email): BOOL (Re.match (R"^ ([a-za-z]+) ([0-9]*) @ ([a-z0-9a-z]+\.) +[a-za-z]{2,}$", email, re. IGNORECASE)) if isMatch: "email is correct. " Else : " email is wrong. " return IsMatch
Python Regular Expressions