Regular Expression Learning

Learn regular expressions by seeing patterns, test cases, and match results side-by-side

Welcome to Regular Expression Learning

View Source on GitHub

This documentation demonstrates how regular expressions work by showing the pattern, test input, and match results side-by-side. Each example uses Python's re module with clear explanations of what each pattern does.

How to Use This Guide

Each example includes:

  • Pattern: The regular expression pattern
  • Test Input: Sample text to match against
  • Match Results: What matched, captured groups, and whether each test case succeeded
  • Explanations: Detailed breakdown of how the pattern works

Python re Module

All examples use Python's standard re module. The patterns shown work with:

  • re.search(): Find first match
  • re.findall(): Find all matches
  • re.match(): Match at beginning of string
  • re.sub(): Replace matches

Learning Path

Start with Basic Patterns to understand character matching and simple quantifiers. Progress through Character Classes and Anchors to gain more control. Then explore Groups and Capturing to extract data. Finally, study Practical Examples for real-world use cases like email validation and data parsing.

Available Topics

Basic Patterns

Learn fundamental regex patterns including literal characters, wildcards, and basic quantifiers

5 examples

Character Classes

Match specific sets of characters using character classes and ranges

4 examples

Anchors and Boundaries

Control where matches occur using anchors and word boundaries

3 examples

Groups and Capturing

Extract and organize matched data using capturing groups

3 examples

Advanced Patterns

Use alternation and lookaround assertions for complex matching

3 examples

Practical Examples

Real-world regex patterns for common tasks

8 examples