# Regex Tester
Stdlib `re`-based regex matcher/explainer.
```
python scripts/run.py '(\d{4})-(\d{2})' '2026-06 and 2025-12'
python scripts/run.py '(?P<user>\w+)@(?P<dom>[\w.]+)' '[email protected]'
python scripts/run.py 'cat' 'concatenate' --sub dog
```
---
name: regex-tester
display_name: Regex Tester
description: "Test a regular expression against sample text and explain what it matches. Use when the user has a regex and wants to see matches, groups, or debug why it does/doesn't match. Triggers: test regex, regex match, regular expression, does this regex match."
---
# Regex Tester
Test and debug regular expressions against sample text.
## When to use
User gives a regex pattern and sample text and asks "what does this match?", "why doesn't it match?", or wants named/numbered capture groups extracted.
## How to use
`python scripts/run.py '<pattern>' '<text>' [--flags imsx] [--sub REPLACEMENT]`
- Prints every match with start/end offsets and all capture groups (named + numbered).
- `--flags` accepts any of `i` (ignorecase), `m` (multiline), `s` (dotall), `x` (verbose).
- `--sub` performs a substitution and prints the result.
- Pass text as `-` to read from stdin.
## Pitfalls
- Escape backslashes when typing inline; prefer single quotes around the pattern.
- A catastrophic-backtracking pattern can hang — the script enforces a match cap.
Regex Tester by langbot-team
Test a regular expression against sample text and explain what it matches.
Loading...