Python Regex (original) (raw)

Skip to content

A regular expression (or regex) is a sequence of characters that specifies a search pattern. In practice, you’ll find the regular expressions in many applications such as search engines, search and replace dialogs of text editors.

In Python, a regular expression is a separate programming language. It is embedded in Python. To interact with the regular expressions, you use the built-in re module:

The re module has many helpful classes and functions that help you to manage regular expressions effectively.

Section 1. Basic Regular Expressions #

This section introduces the regular expression basics including functions, character sets, anchors, and word boundaries.

Section 2. Quantifiers #

This section shows you how to apply quantifiers to specific parts and two modes of quantifiers including greedy and lazy.

Section 3. Sets and Ranges #

This section covers the sets and ranges to match the characters.

Section 4. Grouping #

This section shows you how to use the grouping to extract portions of information, reference the preceding group, and apply alternation.

Section 5. Look Around #

This section explains the concepts of different types of look-around mechanisms.

Section 6. Python regex functions #

This section discusses the regular expression functions in the re module in detail and the regex flags.

Section 7. Python Regex Cheat Sheet #

Was this tutorial helpful ?