Python Regex Reference

By Xah Lee. Date: . Last updated: .

Regex Basics Tutorial

Python: Regex Basics

Regex Functions

Python Regex Functions

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

Regex Objects

Python Regex Object and 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 Object

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

Regex Pattern Syntax

Python Regex Syntax

Notes and References

Note: This document was originally a rewrite of Python 2.4's Official Documentation of its RE module (http://python.org/doc/2.4/lib/module-re.html), strictly following its style and format. It was written in 2005. However, it has since been rewritten as independent tutorial and reference. For detail, see: Notes on Rewriting Python Regex Documentation

For official python doc on regex, see:

Ask me question on patreon