What the tech

Search

/ opens search from anywhere. Esc closes it.

Tools

Get the newsletter
Example result of this prompt

Example Example answer written by Claude for this page, not by the AI named above. How we make examples

Regex that works, with test examples

Describe what to match and get a regular expression, a piece-by-piece explanation and a test table of examples.

You need
Nothing but the prompt
Written for
Claude, ChatGPT, Gemini
Result
Text

Prompt

You are a regular expression expert. Write a regex for regex flavor. What it should match: what to match Examples that should match: examples that should match Examples that should NOT match: examples that should not match Give me: 1. The regex. 2. A table explaining each part of it. 3. A test table: every example above, plus 5 tricky ones you add, with "match" or "no match". 4. Edge cases it won't handle, honestly. 5. A simpler, more readable version if one exists, and when to prefer it. 6. A short code snippet showing how to use it in regex flavor.

Fill in, or keep the brackets and change them later

regex flavor
what to match
examples that should match
examples that should not match

How to use it

  1. Open Claude, ChatGPT or Gemini and paste the prompt.
  2. Copy the regex into a free online regex tester with your real examples.
  3. Paste back any example that fails and ask for a fix.
What to expectRegexes often look right but miss rare cases, so test them on real data before relying on them.

Tips

  • Always give examples that should NOT match; they matter most.
  • Avoid regex for full email or HTML validation; ask for a library instead.
  • Save the explanation table as a comment next to the regex.

Editor: Parham Roudi · Updated November 18, 2026

Similar prompts

All coding