Prompt LibraryEngineering

Regex Pattern Builder & Explainer Prompt

Build a regex from a natural-language spec and explain it.

The prompt

Build a regular expression that matches the requirement below.
Return:
1. The regex (flavor: {{flavor}}).
2. A line-by-line explanation of each group/quantifier.
3. Three strings that match and three that should not match.
4. One edge case the regex does not handle.

Requirement: {{requirement}}

Replace the {{fields}} with your own context and tighten the rules to match your domain.

Share this prompt