Skip to main content

regex-buddy

Plain English to Regex - Your friendly regex helper.

Stop struggling with regex syntax. Just describe what you want to match in plain English.

Key Features:

  • 24+ built-in patterns with explanations
  • Debug why your regex doesn't match (the killer feature!)
  • Plain English to regex conversion
  • Quick reference cheatsheet with escape guide
  • Interactive regex builder
  • Auto-diagnose problems when testing fails

Installation

pip install regex-buddy

Quick Start

# Get a pattern by name
regex-buddy get email

# List all available patterns
regex-buddy list

# Test a pattern against text
regex-buddy test email -t "Contact us at hello@example.com"

# Find a pattern by description
regex-buddy find "match phone numbers"

# Interactive mode
regex-buddy interactive

Built-in Patterns

regex-buddy comes with 25+ pre-built patterns:

Pattern Description
email Match email addresses
phone Match US phone numbers
url Match URLs (http/https)
ipv4 Match IPv4 addresses
date-mdy Match dates (MM/DD/YYYY)
date-ymd Match dates (YYYY-MM-DD)
time Match time (12 or 24 hour)
credit-card Match credit card numbers
ssn Match Social Security Numbers
zip Match US ZIP codes
hex-color Match hex color codes
username Match usernames
password-strong Match strong passwords
slug Match URL slugs
hashtag Match #hashtags
mention Match @mentions
uuid Match UUIDs
html-tag Match HTML tags
markdown-link Match Markdown links
number Match numbers
word Match whole words

Usage Examples

Get a Pattern

$ regex-buddy get email

[email]
  Pattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
  Description: Match email addresses

  Python: r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"
  JavaScript: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g

Get with Explanation

$ regex-buddy get email -v

[email]
  Pattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
  Description: Match email addresses

  Breakdown:
    [a-zA-Z0-9._%+-]+ - Username (letters, numbers, dots, underscores, etc.)
    @ - The @ symbol
    [a-zA-Z0-9.-]+ - Domain name
    \. - A literal dot
    [a-zA-Z]{2,} - Top-level domain (com, org, etc.)

  Examples that match:
    user@example.com
    test.email+tag@domain.co.uk

Test a Pattern

$ regex-buddy test email -t "Send to john@example.com or jane@test.org"

Matches found: 2

Matches:
  1. john@example.com
  2. jane@test.org

Find by Description

$ regex-buddy find "match urls"

Found built-in pattern: url
  Pattern: https?://(?:www\.)?...
  Description: Match URLs (http and https)

Debug Why It Doesn't Match (The Killer Feature!)

$ regex-buddy debug "www.google.com" "visit www.google.com today"

Debugging pattern: www.google.com
Against text: visit www.google.com today

Pattern DOES match: ['www.google.com']

Suggestions:
  - '.' in your pattern: Dot matches ANY character. Use \. for literal dot
  - Consider using \b for word boundaries to avoid partial matches

The debug command catches common issues:

  • Unescaped special characters (dots, asterisks, etc.)
  • Case sensitivity problems
  • Anchor issues (^ and $)
  • Greedy vs lazy matching
  • Missing word boundaries
  • Shows partial matches to help you find where it breaks

Cheatsheet

# Quick reference
$ regex-buddy cheatsheet

# Escape guide (what characters need escaping)
$ regex-buddy cheatsheet -e

Explain Any Pattern

$ regex-buddy explain "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"

Pattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

Breakdown:
  [a-zA-Z0-9._%+-] - Any character in: a-zA-Z0-9._%+-
  + - One or more of previous
  [a-zA-Z] - Any character in: a-zA-Z
  {2,} - 2 or more times

Potential issues:
  - Unescaped '.' - matches ANY character. Did you mean '\.'?

Interactive Mode

$ regex-buddy interactive

regex-buddy interactive mode
Commands: list, get <name>, test <pattern>, explain <pattern>, find <description>, quit

regex> get phone
regex> test email
Enter text to test (empty line to finish):
my email is test@example.com
please reply to hello@world.org

Matches found: 2

Python API

from regex_buddy import (
    get_pattern, test_pattern, list_patterns,
    debug_no_match, check_common_mistakes, RegexBuilder
)

# Get a pattern
email_pattern = get_pattern("email")
print(email_pattern["pattern"])
# [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

# Test a pattern
result = test_pattern(email_pattern["pattern"], "Contact: user@example.com")
print(result["matches"])
# ['user@example.com']

# Debug why something doesn't match
diag = debug_no_match(r"www.google.com", "visit www.google.com")
print(diag["suggestions"])
# ['Dot matches ANY character. Use \\. for literal dot', ...]

# Check for common mistakes before they cause problems
warnings = check_common_mistakes(r"(a+)+")
# [{'type': 'catastrophic_backtracking', 'message': '...'}]

# Build patterns interactively
builder = RegexBuilder()
pattern = (builder
    .start()
    .digits(exact=3)
    .literal("-")
    .digits(exact=4)
    .end()
    .build())
print(pattern)  # ^\d{3}\-\d{4}$

# List all patterns
patterns = list_patterns()
for name, description in patterns.items():
    print(f"{name}: {description}")

Support

If you find this project useful, consider supporting its development:

License

MIT License

Metadata

Release files for regex-buddy 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for regex-buddy 1.0.0
File Size Uploaded
regex_buddy-1.0.0.tar.gz 22.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for regex-buddy 1.0.0
File Interpreter ABI Platform
regex_buddy-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.8 kB

Release files / regex_buddy-1.0.0.tar.gz

Download URL regex_buddy-1.0.0.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
770bb0a9abe00afc37798f10e8542c1af7f1cd9fac272ac57f0e935536717f20
BLAKE2b-256 checksum
How to use checksums
00ee3d5c9f16d636e4f3970a539dbf4dfa3fa36a5512b0f7affc936da965cbcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / regex_buddy-1.0.0-py3-none-any.whl

Download URL regex_buddy-1.0.0-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad267f6328ef406cc5b779dcbca49e86f5c3d31415e6ed78b059d11b98835f3e
BLAKE2b-256 checksum
How to use checksums
e4e571be64ee1fb953575ee4c43da1abd220d022869c28d695b658367cf327d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page