PlaybookPrompts

Generate a regex with a built-in test matrix

Coding & Development regextesting

Regex without test cases is a bug waiting to land. This prompt forces the model to produce a test matrix alongside the expression.

Prompt
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.
Variables to fill in
  • {{DESCRIPTION}}
  • {{REGEX_FLAVOR}}

How to use this prompt

  1. Copy the prompt above (Copy button on the top-right).
  2. Replace each {{VAR}} with your own value. Variables: {{DESCRIPTION}}{{REGEX_FLAVOR}}.
  3. Paste it into one of the recommended tools below.
  4. 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.

Heads up: some of the links on this page are affiliate links — meaning we may earn a commission if you sign up after clicking, at no extra cost to you. We only recommend tools we'd put on our own stack. You can see our full affiliate disclosure here.

Pair this prompt with a tool

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.