The re module

Regular Expression Matching

     re.compile(pattern,flags)        # Compile regular expression string
     re.search(pattern, str)          # Search for first match of pattern 
     re.match(pattern,str)            # Checks if str matches pattern
     re.sub(pattern, repl, str)       # Replace pattern with repl 

Patterns

     text                  Matches literal text
     .                     Match any character except newline
     ^                     Match the start of a string
     $                     Match the end of a string
     *                     Match zero of more repetitions
     +                     Match one or more repetitions
     ?                     Match zero or one repetitions
     [...]                 Match a set of characters
     (...)                 Match expression in parenthesis as a group
     A|B                   Match A or B
<<< O'Reilly OSCON 2000, Introduction to Python, Slide 124
July 17, 2000, beazley@cs.uchicago.edu
>>>