15. Module re#
Python uses re module to work with regular expressions.
Core functions of re module:
match- searches a sequence at the beginning of the linesearch- searches for first match with templatefindall- searches for all matches with template. Returns the resulting strings as a listfinditer- searches for any matches with template. Returns an iteratorcompile- compiles regex. You can then apply all of listed functions to this objectfullmatch- the entire line must conform to regex described
In addition to functions that search matches, module has the following functions:
re.sub- for replacement in stringsre.split- to split string into parts