The Python Regular Expression module is re.
Common steps to use a regular expression:
1. First Use Re. Compile to compile a regexobject to indicate a Regexp
2. Use the match and search methods of pattern to obtain the matchobject.
3. Use matchobject to obtain the matching position, matched string, and other information.
Common regexobject functions:
Reobj. Match (STR [, POS [, endpos]) if the start of STR matches reobj, A matchobject is returned; otherwise, none is returned.
Reobj. Search (STR [, POS [, endpos]) Searches str for the first part that matches reobj.
Reobj. findall (STR) searches for all matching parts in STR and returns a tuple, which is a matched string.
Matchobject common functions:
M. Start () returns the start position. For reobj. Match (), start () always returns 0
M. End () returns the end position (excluding the characters of this position)
M. span () returns a tuple representation (M. Start (), M. End ())
M. pos (), M. endpos (), M. Re (), and M. String () indicate the parameters in the matchobject function.
M. finditer () returns an iterator to traverse all the matchobjects found.