Test, find, replace, explain, and validate regular expressions. Includes 25+ common named patterns. Pure Python, no dependencies.
bash
# Test a pattern
python3 scripts/regex_toolkit.py test '\d+' --text 'abc 123 def'
# Use a named pattern (email, url, ipv4, phone-us, uuid, etc.)
python3 scripts/regex_toolkit.py findall email --text 'Contact hello@example.com or support@test.org'
# Find all matches with positions
python3 scripts/regex_toolkit.py findall '\b\w{5}\b' --file input.txt
# Search and replace
python3 scripts/regex_toolkit.py replace '\bfoo\b' -r bar --text 'foo bar foo'
# Explain a regex in plain English
python3 scripts/regex_toolkit.py explain '(?P<year>\d{4})-(\d{2})-(\d{2})'
# Validate regex syntax
python3 scripts/regex_toolkit.py validate '[a-z'
# List all common patterns
python3 scripts/regex_toolkit.py patterns --list
# Pipe from stdin
echo "Call 555-1234 or 555-5678" | python3 scripts/regex_toolkit.py findall phone-us
CommandDescriptiontestCheck if pattern matches. Shows first match position and groups.findallFind all matches with positions and captured groups. --json for JSON output.replaceRegex search-and-replace. Supports \1 backreferences. --count N limits replacements.explainBreak down a regex into plain-English explanation of each element.validateCheck if a regex pattern is syntactically valid.patternsList built-in common patterns or show a specific one by name.
All matching commands accept: --text 'string', --file path, or piped stdin.
FlagDescription-i, --ignorecaseCase-insensitive matching-m, --multiline``^/ $ match line boundaries-s, --dotall``. matches newline
Use by name instead of writing regex: email, url, ipv4, ipv6, phone-us, phone-intl, date-iso, date-us, time-24h, hex-color, mac-address, uuid, ssn, zip-us, credit-card, slug, semver, domain, hashtag, mention, markdown-link, html-tag, json-key, filepath-unix, filepath-win.