Get Started
Coding

Build and understand a regex

Produces a regex with a piece-by-piece breakdown and its failure cases.

Prompt
I need a regular expression that matches: {{requirement}}

Should match:
{{should_match}}

Should NOT match:
{{should_not_match}}

Give me:
1. The regex
2. A breakdown of every component and what it does
3. Test results against each of my examples above
4. Two inputs that would break it unexpectedly
5. A plain-code alternative if regex is the wrong tool here

Flavour: {{language}}

Fill these in

Replace each highlighted variable before sending. Leaving them in place is the most common reason these prompts under-perform.

VariableWhat to putExample
{{requirement}}What to matchNepali mobile numbers
{{should_match}}Positive examples9841234567, +9779841234567
{{should_not_match}}Negative examples1234567890
{{language}}Regex flavourJavaScript

Tips for better output

  • Point 5 matters: regex is often the wrong answer, and a good model will say so.
  • Always test the two 'breaking' inputs it gives you.

Works well with

More coding prompts