Generate a regex with a built-in test matrix
Regex without test cases is a bug waiting to land. This prompt forces the model to produce a test matrix alongside the expression.
Generate a regex for: {{DESCRIPTION}}
Flavor: {{REGEX_FLAVOR}} (PCRE / ECMAScript / Python / etc.)
Deliverable:
1. The regex itself.
2. A plain-English explanation, broken down by group.
3. A test matrix with at least 8 cases:
- 4 strings that must match (with the captured groups)
- 4 strings that must NOT match (with the reason)
4. The worst-case input that could cause catastrophic backtracking, or 'none known' with reasoning. {{DESCRIPTION}}{{REGEX_FLAVOR}}
How to use this prompt
- Copy the prompt above (Copy button on the top-right).
- Replace each
{{VAR}}with your own value. Variables:{{DESCRIPTION}}{{REGEX_FLAVOR}}. - Paste it into one of the recommended tools below.
- Iterate: tighten constraints in the prompt if the output is generic.
Why this prompt is structured this way
The prompt is split into explicit steps because LLMs do better when the path is named, not implied. Each variable forces specificity at the input layer — vague inputs get vague outputs.
Pair this prompt with a tool
Claude (Anthropic)
$0/mo (Pro at $20)Frontier model with long context and strong reasoning.
Claude (Opus / Sonnet / Haiku tiers) is the assistant favored by writers and engineers who care about reasoning quality and tone. 1M token context on Opus.
ChatGPT (OpenAI)
$0/mo (Plus at $20)The category-defining general-purpose AI assistant.
ChatGPT has the broadest feature surface: image gen, voice, custom GPTs, web browsing, code execution. Often the right default; sometimes beaten on specific tasks by Claude or Perplexity.
Cursor
$20/moAI-first code editor forked from VS Code.
Cursor is VS Code with first-class LLM integration. Multi-file edits, codebase Q&A, autocomplete that's actually useful. The default IDE for many shipping engineers in 2026.
The PlaybookPrompts weekly
One short email per week. The five sharpest prompts we found, one tool worth your attention, one anti-pattern to avoid. Unsubscribe in one click.
Newsletter signup is not configured. Set PUBLIC_NEWSLETTER_USERNAME in the build env.