Grow AI Skills Saved
✳ PromptAdapted resource

Regex with Test Cases Prompt

Generate a regex for a specified engine and check it against explicit examples and counterexamples.

By Ersin Yılmaz·Development

Free prompt · No skill to install

What this prompt does

  • Engine awareness

    Respect the syntax and flags of the specified regex engine.

  • Examples and negatives

    Check desired matches and counterexamples together.

  • Execution boundary

    Separate expected outcomes from actual engine results.

What to provide & what you get

Input
The regex engine, matching rule, should-match examples and should-not-match examples.
Expected output
A copyable pattern, flags, example results and limitations for the chosen engine.

How to use

  1. Specify the engine, match scope and positive/negative cases.
  2. Test the returned pattern in that engine.
  3. Add boundary inputs and review any performance-sensitive use.

Check the result: All provided cases should produce the intended result in the actual engine.

Copy. Paste. Run.

v1.0.0-gas1

Edit the inputs below, then copy into your AI tool with the requested source material.

Before you start

  • The regex engine, matching rule, should-match examples and should-not-match examples.
Edits stay in this tab

Worked example · Editorial fixture

Reject substring matches when a whole identifier is required

Original fictional inputs and a prepared editorial answer. This reusable prompt was not run against the fixture. Use the files and case-specific checks to review your own result.

Example input

Engine: Node.js v24.19.0, ECMAScript RegExp. Whole string must be TASK- followed by exactly four ASCII digits. No trimming; no flags. Inputs include a trailing newline and non-ASCII digits.

Prepared output

RAW PATTERN: ^TASK-[0-9]{4}(?![\s\S])
JAVASCRIPT LITERAL: /^TASK-[0-9]{4}(?![\s\S])/
FLAGS: none.

OBSERVED: TASK-0001 and TASK-9999 match. Lowercase, 3 or 5 digits, a trailing newline, a leading x, Arabic-Indic digits and empty input do not.
WHY THE REPAIR: /TASK-\d{4}/ accepts the substring inside xTASK-1234. The corrected start anchor and final negative lookahead require the whole string, with no remaining character.
BOUNDARY: this validates the stated identifier shape only, not whether a task exists.

What to check in this case

  • All nine cases were executed in the specified Node engine; raw output is in checks.json.
  • The deliberately faulty pattern demonstrates one observed false positive; the corrected pattern rejects it.

References: MDN: JavaScript regular expressions

Keep in mind

  • Regex syntax and matching behavior vary by engine.
  • Untested patterns and expected results are not execution evidence.

Keep exploring

Related skills & prompts

Browse this category ↗
↗ Skill
DevelopmentGitHub pick

Python Testing

Build focused pytest tests using fixtures, parametrization and useful failure cases.

Codex · Claude Code↓ ZIP