July 2007
Intermediate to advanced
128 pages
2h 39m
English
The re module defines all regular expression functionality. Pattern matching is done directly through module functions, or patterns are compiled into regular expression objects that can be used for repeated pattern matching. Information about the match, including captured groups, is retrieved through match objects.
Python’s raw string syntax, r'' or r"", allows you to specify regular expression patterns without having to escape embedded backslashes. The raw-string pattern, r'\n', is equivalent to the regular string pattern, \\n. Python also provides triple-quoted raw strings for multiline regular expressions: r'''text''' and r"""text""".