← Back to all products
$9
Regex Cheatsheet & Patterns
Regular expression syntax reference with 100+ tested patterns for validation, parsing, extraction, and text manipulation.
MarkdownJSONYAMLPython
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 3 files
regex-pattern-library/
├── LICENSE
├── README.md
└── config.example.yaml
📖 Documentation Preview README excerpt
Regex Cheatsheet & Patterns
Complete regular expression reference with 100+ tested patterns organized by use case. Covers syntax, flags, lookahead/lookbehind, and real-world patterns for validation, parsing, extraction, and text manipulation.
Who Is This For?
- Developers who need ready-to-use regex patterns for common tasks
- Data engineers parsing logs, CSVs, and semi-structured data
- DevOps engineers writing grep, sed, and log processing rules
- Anyone who uses regex regularly but can't memorize the syntax
What's Inside
Cheatsheet Files (`cheatsheets/`)
| File | Topics Covered |
|---|---|
01-syntax-reference.md | Character classes, quantifiers, anchors, groups, alternation, escaping -- the complete regex syntax in table form |
02-flags-and-modes.md | Global, case-insensitive, multiline, dotall, unicode, named groups, possessive quantifiers |
03-lookahead-lookbehind.md | Positive/negative lookahead and lookbehind with practical examples and performance notes |
04-validation-patterns.md | 30+ patterns for email, URL, IP, phone, date, credit card, password strength, username, UUID, etc. |
05-parsing-patterns.md | 25+ patterns for log files, CSV, key-value pairs, HTML tags, JSON values, config files, SQL |
06-extraction-patterns.md | 25+ patterns for extracting data from text: numbers, dates, emails, URLs, hashtags, mentions, file paths |
07-manipulation-patterns.md | 25+ patterns for find-and-replace: whitespace normalization, case conversion, string cleanup, formatting |
08-language-specific.md | Regex syntax differences across Python, JavaScript, Java, Go, and PCRE. Escape rules, flag syntax, named groups |
Example Files (`examples/`)
| File | Description |
|---|---|
test_patterns.py | Python script that tests all 100+ patterns against sample inputs |
regex_tester.py | Interactive regex tester -- enter a pattern and test string, see matches |
sample_data.txt | Sample text with emails, URLs, dates, IPs, and log entries for testing |
Quick Reference (`cheatsheet.html`)
Self-contained HTML file with the regex syntax tables and most-used patterns. Print-friendly.
How to Use
1. Unzip the archive
2. Browse cheatsheets/ -- start with 01-syntax-reference.md for the fundamentals
3. Find patterns by use case in files 04-07 (validation, parsing, extraction, manipulation)
4. Test patterns using examples/regex_tester.py or an online tool
5. Run examples/test_patterns.py to verify all patterns work
Pattern Table Format
Every pattern includes:
| Column | Description |
|---|---|
| Pattern | The regex pattern |
| Matches | What it matches (with examples) |
| Doesn't Match | What it correctly rejects |
| Notes | Caveats, edge cases, alternatives |
Format Notes
- Patterns use PCRE-compatible syntax (works in Python, JavaScript, Java, etc.)
... continues with setup instructions, usage examples, and more.
📄 Code Sample .py preview
examples/regex_tester.py
#!/usr/bin/env python3
"""
Interactive Regex Tester
========================
A command-line tool for testing regex patterns against input text.
Supports all Python re flags, shows match groups, and provides
helpful feedback for common regex mistakes.
Usage:
python3 regex_tester.py # Interactive mode
python3 regex_tester.py -p "\\d+" -t "abc 123 def 456" # One-shot mode
python3 regex_tester.py -f sample_data.txt -p "\\d+" # Test against file
Requires: Python 3.8+ (stdlib only)
"""
import re
import sys
import argparse
from typing import Optional
# ---------------------------------------------------------------------------
# ANSI color helpers (works in most modern terminals)
# ---------------------------------------------------------------------------
class Colors:
"""ANSI color codes for terminal output."""
RED = "\033[91m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
BLUE = "\033[94m"
MAGENTA = "\033[95m"
CYAN = "\033[96m"
BOLD = "\033[1m"
DIM = "\033[2m"
RESET = "\033[0m"
UNDERLINE = "\033[4m"
@classmethod
def disable(cls) -> None:
"""Disable colors (for piped output)."""
for attr in ["RED", "GREEN", "YELLOW", "BLUE", "MAGENTA", "CYAN",
"BOLD", "DIM", "RESET", "UNDERLINE"]:
setattr(cls, attr, "")
# Disable colors if output is piped
if not sys.stdout.isatty():
# ... 396 more lines ...