Python Regex Reference

, , …,

This module provides a way to search/replace a string by a pattern, known as Regular Expression or regex.

Regex Functions

Python Regex Functions

For vast majority of uses, you want the .search(…) and .sub(…) and .split(…) functions.

Regex Objects

Python Regex Object & Methods

For writing code using Object Oriented style.

Python Regex Flags

Python Regex Flags

Options for regex methods that change regex pattern's meaning.

Regex Match Objects

Python Regex Match Objects

Some function or method return their result as object called “MatchObject”.

Regex Pattern Syntax

Python Regex Syntax

Notes & References

Note: This document was originally a rewrite of Python 2.4's Official Documentation of its RE module (, strictly following its style & format. It was written in 2005. However, it has since been rewritten as independent tutorial & reference. For detail, see: Notes on Rewriting Python Regex Documentation

For current official python doc on regex, see:

blog comments powered by Disqus