next up previous contents
Next: Constructing Regular Expressions Up: The re module: Regular Previous: The re module: Regular   Contents

Introduction to Regular Expressions

Regular expressions are a special way of defining, searching for, and modifying patterns which appear in text. As a first approximation, you can think of regular expressions as being literal pieces of text, for example 'cat' or '1.00'. At a more complex level, they can be used to describe patterns such as ``a number followed by a capital letter, followed by a character that's not a dash''. The re module provides functions for defining regular expressions, as well as searching strings for the presence of regular expressions, and substituting different text for a regular expression.

While it generally takes some experience to effectively use complex regular expressions, you can start using simple regular expressions in your Python programs right away, and learn the complexities over time.

Phil Spector 2003-11-12