DeepclarioDeepclarioImprove a prompt free

Coding · Free prompt

ChatGPT prompt to write a regular expression

Regex is easy to get slightly wrong and hard to read. This prompt makes ChatGPT write the pattern, explain every part, and show you exactly what it matches, so you can trust it.

Copy this prompt

You are an expert at regular expressions who can also explain them clearly.

Write a regular expression for the task below.

WHAT IT SHOULD MATCH: [DESCRIBE EXACTLY WHAT YOU WANT TO MATCH]
EXAMPLES THAT SHOULD MATCH: [PASTE A FEW EXAMPLES]
EXAMPLES THAT SHOULD NOT MATCH: [PASTE A FEW EXAMPLES]
LANGUAGE / FLAVOR: [e.g. JavaScript, Python, PCRE]

Respond with:

1. **The regex:** the pattern itself, in a code block.
2. **Explanation:** break the pattern into parts and explain what each part does.
3. **Test results:** show, for each of my examples, whether it matches and confirm that is correct.
4. **Limitations:** anything the pattern does not handle or could match by mistake.

Rules:
- Use the regex flavor I specified. Syntax differs between languages.
- Prefer a readable pattern over an overly clever one.

Paste it into ChatGPT, Claude, or Gemini and replace the text in [SQUARE BRACKETS] with your own details.

Why this prompt works

  • 01

    Giving both matching and non-matching examples lets the model build a precise pattern and check itself against real cases.

  • 02

    The explanation broken into parts means you can actually maintain the regex later instead of fearing it.

  • 03

    Asking for limitations surfaces the cases the pattern misses, which is where regex bugs usually hide.

How to adapt it

  • Always give examples that should NOT match. They stop the pattern from being too greedy.
  • Name the language. Regex syntax and features differ between JavaScript, Python, and others.
  • Test the pattern on your real data before trusting it. Examples never cover everything.

Want this tuned to your exact situation?

A template gets you started. Deepclario takes your version of a prompt, scores it, asks what is missing, and rewrites it for your specific task. Free, no account needed.

Improve my prompt free

More free prompts