Regex Builder With Test Cases
Builds a regular expression from plain English and proves it with matching and non-matching examples.
The prompt
Remixed ·Fill in the variables
The prompt above updates live. Nothing leaves your browser.Remix it
One-click variations. Stack them, then copy.
Why this prompt works
Positive and negative examples act as few-shot specs, which pins down ambiguous requirements. The self-test table catches mistakes immediately, and asking whether a parser would be safer prevents regex for jobs regex should not do.
Framework: Few-Shot. Shows one or more examples of the output you want.
Example
Illustrative, not a real model outputExample input
- [REGEX_FLAVOUR]
- JavaScript
- [WHAT_TO_MATCH]
- Canadian postal codes
- [EXAMPLES_THAT_MATCH]
- T2P 1J9, t2p1j9
- [EXAMPLES_THAT_DONT]
- D2P 1J9, T2P-1J9X
What a good answer looks like (abridged)
How to use it
- Fill in 4 variables below (or in the prompt) with specific details.
- Paste it into ChatGPT (also works in Claude, Gemini, Grok).
- Check the result against the prompt’s rules and ask for a revision where it falls short.
ChatGPT tips
- Put the output format (schema, table columns) near the top: ChatGPT follows explicit structure very reliably.
- Use a Project or custom instructions for prompts you reuse daily.
Common mistakes
- Leaving [VARIABLES] unfilled or vague ("my business") instead of specific ("a 3-person Calgary bakery").
- Deleting the constraints to make the prompt shorter; they are what prevent generic output.
- Accepting the first answer. Reply with what to fix and ask for a revision.
Guide: Promptnic template.
Frequently asked questions
Which AI model works best with the Regex Builder With Test Cases prompt?+
It is tuned for ChatGPT and also works in Claude, Gemini, Grok, DeepSeek. Put the output format (schema, table columns) near the top: ChatGPT follows explicit structure very reliably.
How do I use this prompt?+
Copy it, replace the 4 [VARIABLES] (regex flavour, what to match, examples that match…) with your details, then paste it into ChatGPT. You can fill the variables on this page and copy the finished version.
Is this prompt free to use?+
Yes. Every prompt on Promptnic is free to copy, adapt and use in personal or commercial work. A link back is appreciated, not required.
Why does this prompt work?+
Positive and negative examples act as few-shot specs, which pins down ambiguous requirements. The self-test table catches mistakes immediately, and asking whether a parser would be safer prevents regex for jobs regex should not do.
Related prompts
Error Message Translator
Explains a cryptic error in plain English, lists likely causes for your setup and gives the fix commands.
Root-Cause Bug Hunter (Hypotheses Before Patches)
Forces the model to isolate the failure, rank root causes and write a regression test before it touches your code.
Performance Detective
Finds the real bottleneck in slow code or queries, estimates impact and proposes fixes ranked by effort.
Startup Idea Stress Test
Tears apart a startup idea like a sharp investor, then suggests how to de-risk it cheaply.
Strict JSON Extractor With Self-Check
Pulls structured data out of messy text into an exact JSON schema, with nulls instead of made-up values.
README That Gets People to Try Your Project
Writes a README with a one-line pitch, quick start that works on the first try, and honest limitations.