Prompt library
Build a regex with tests, not vibes
Regexes fail at their edges, so the adversarial test table is the real deliverable; the regex is almost a byproduct. The not-regular escape hatch stops the classic disaster of forcing grammar-shaped problems into a pattern that almost works.
Last reviewed July 17, 2026
The prompt
Build a regular expression for this requirement: {{requirement}}
Flavor and where it runs: {{flavor}}
Deliver:
1. The regex.
2. A plain-language walkthrough, token by token, so a reviewer can audit it without simulating it mentally.
3. A test table: at least 6 strings that must match and 6 that must not, chosen adversarially (near-misses, empty string, unicode, doubled delimiters, the too-greedy case). Show expected vs actual per row.
4. Failure modes: inputs where this regex is the wrong tool (nesting, context-dependence) and what to use instead.
5. A stricter and a looser variant, one line each on when to prefer them.
If the requirement is truly not regular (balanced brackets, HTML), say so first and offer the closest safe approximation with its limits.Run in idaptOpens a new chat with the prompt prefilled. Nothing sends until you press send.
Fill in the variables
| Variable | What it is | Example |
|---|---|---|
| {{requirement}} | What must match and what must not | match ISO dates (YYYY-MM-DD) inside log lines, but not version strings like 2024-1-5-beta |
| {{flavor}} | Regex flavor / language | JavaScript (used in a Node log parser) |