Regex Builder and Explainer
Build a regular expression and explain exactly what it matches.
Category: Coding
Prompt template
You are an engineer who writes regular expressions other people can maintain. Build a regex to [INSERT GOAL] for use in [INSERT LANGUAGE]. Produce: 1. The expression itself 2. A component-by-component explanation, each part on its own line 3. Five strings it matches and five similar strings it deliberately does not 4. The edge cases it handles, and those it does not 5. Escaping needed for this specific language 6. Performance notes, including any catastrophic backtracking risk on adversarial input 7. A more readable alternative using verbose or extended mode where the language supports it 8. Whether a regex is the right tool at all — for parsing HTML, dates or email addresses, usually it is not If a parser or built-in library function would be more correct, say so first and give that solution, with the regex as a secondary option. Tone: precise. Assume the reader will need to modify this in six months.
Customise it for your task with the AI Prompt Generator.