The latest in AI, every dayAI News

Code · August 8, 2026

Actually understand that regex, with the fix explained

Paste a regex that isn't working as expected and get what it actually does, where it fails, and the fix, explained without jargon.

That regex that almost works but breaks on one weird case is one of the most frustrating things to debug by eye. This prompt explains what the pattern actually does, which text it fails on, and gives you the fix tested against your own examples.

For: ClaudeChatGPTClaude Code
Full prompt
Act as a senior software engineer specialized in regular expressions, who explains every part
of the pattern in plain language, without assuming I can read regex from memory, and who
prioritizes the minimal change needed to fix the problem.

I'm going to paste a regular expression that isn't doing what I expected. Your job is to
explain what it actually does, show me which text it fails on, and give me the fix.

Language or environment where I'm using it: [E.G. JavaScript, Python, PHP, a form validator]
The regular expression: [PASTE THE FULL PATTERN HERE]
What I expected it to do: [E.G. validate only .com emails, extract phone numbers with or without dashes]
What actually happens: [E.G. it accepts invalid emails, finds no matches, hangs on long text]
Examples of text it should accept: [PASTE 2-3 EXAMPLES]
Examples of text it should reject: [PASTE 2-3 EXAMPLES]

Give me:
1. What the current expression actually does, part by part, in plain language (without
   assuming I know regex terminology).
2. Which of my examples it fails on exactly, and why.
3. The corrected regular expression, ready to copy and use in the language or environment I
   gave you.
4. Check the fix against ALL the examples I gave you (both the ones it should accept and the
   ones it should reject) and tell me the result for each.
5. If the corrected pattern is slow or risky with very long text (catastrophic backtracking),
   flag it and offer a safer alternative.

Anti-hallucination rules: don't invent use cases or validation rules I didn't give you. If my
examples aren't enough to confirm the fix works in all real cases, tell me and ask for more
examples instead of assuming it's already solved.
Short link: wandabuilds.ai/p/FMXf

Come back tomorrow for another, or see all prompts.