How to use this prompt
- Describe what to match and give examples that should and should not match. Examples make regex accurate.
- Pick the language or tool, because regex rules differ slightly.
- Click Generate prompt, then Copy prompt or open it in ChatGPT, Claude, Gemini, Copilot, Perplexity, Grok or any AI app.
- Test the regex in your code or an online regex tester with your real data.
Regex tips
- Simple and readable beats clever. Add comments when the pattern is long.
- For emails, a simple check plus a confirmation email is better than a giant regex.
- Need formulas instead? Use the Excel & Google Sheets Formula Helper.
- Do not understand an old pattern? Paste it into the Code Explainer.
Example: how to fill it in
Here is how a developer might fill in the form for a form field.
| Field | Example answer |
|---|---|
| What to match | Order numbers like ORD-2026-00123 |
| Should match | ORD-2026-00123 and ORD-2025-99999 |
| Should not match | ord-2026-00123, ORD-26-123 and ORD-2026-123456 |
| Task | Validate a whole input |
| Language or tool | JavaScript |
Common mistakes and how to fix them
- No examples. Give strings that should and should not match.
- Wrong flavour. Regex differs between tools. Pick yours.
- Over-complex patterns. Long patterns are hard to fix later. Keep it simple.
- Client-side only validation. Always check input on the server too.
Follow-up prompts to try
After the first result, keep the same chat open and send one of these:
- "Make it case-insensitive."
- "Extract the year and number as separate groups."
- "Use it to find and replace in VS Code."
- "Explain this regex I found online."
Frequently asked questions
What is a regex?
A regular expression: a pattern used to find, check or replace text.
Does it work in Google Sheets?
Yes. Choose Google Sheets and it uses functions like REGEXMATCH.
Can it explain an existing regex?
Yes. Paste it into My current regex.
Should I validate emails with regex?
Use a simple check, then confirm the address by sending an email.
