Python's re modules are commonly used in 5 ways, namely Re.match Re.search re.findall re.split re.sub.
Before you introduce the five methods, you need to introduce the basis of the regular.
. Represents any character, except \ nthe \ escape character [...] character set, which represents whichever character is taken. For example, [abc]d can be matched to an ad BD CD. \d represents a number, equivalent to [0-9]\d represents a non-numeric [^\d]\s represents a space \s represents a non-whitespace \w represents a word character [a-za-z_0-9]\w represents a non-word character [^\w]* matches the preceding 0 or more characters + Match the first 1 or more characters? Matches the preceding 0 or 1 characters {m} matches the preceding M-character {m,n} matches the first 1 characters m to n times ^ matches with what begins $ match with what begins \a match with what begins \z match with what begins | or left and right expressions take a abc|def (..) represents a whole, (ABC) {2} matches ABC2 times (? p<name>) group naming such as (? P<name>tom) \ (number) refers to a group numbered as such as: (\d) abc\1 1ABC1
The re module of the Python Common module (regular)