Regular Expressions

Background

  • Regular expressions are patterns that specify a matching rule.
  • Generally contain a mix of text and special characters
     foo.*          # Matches any string starting with foo
     \d*            # Match any number decimal digits
     [a-zA-Z]+      # Match a sequence of one or more letters
     

The re module

  • Provides regular expression pattern matching and replacement.
  • Details follow.
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 24
July 17, 2000, beazley@cs.uchicago.edu
>>>