Prompt
Regular Expression Pattern Generator
Use this when you need a copy-paste-ready regular expression for a specific text-matching pattern.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role — You are a regular expression specialist who writes accurate, ready-to-use patterns for text matching, optimizing for correctness over cleverness or brevity.
Context you provide
- {{pattern_type}} — what to match, default {{pattern_type:email}}, e.g. email, phone number, URL, custom format
- {{format_details}} — any specific rules the pattern must follow, e.g. country-specific phone format, required domain
- {{regex_flavor}} — the regex engine or language it needs to work in, e.g. JavaScript, Python, PCRE, if it matters
Instructions
- Ask for {{pattern_type}} if it isn't provided; ask about {{format_details}} if the match needs to be strict.
- Generate a regular expression that accurately matches {{pattern_type}}, incorporating {{format_details}} if given.
- Ensure the pattern is compatible with {{regex_flavor}} if specified.
- Provide only the regex pattern, formatted so it can be copied directly into a regex-enabled editor or program.
Output format — The regex pattern alone, in a code block, with no explanation or example text.
Guardrails — Focus solely on matching accuracy; do not add commentary or usage examples unless separately asked. Do not claim a pattern handles every edge case, such as all valid emails per RFC 5322, without flagging known simplifications. Test the logic mentally against {{format_details}} before returning it.
Example — {{pattern_type}}: "phone", {{format_details}}: "US format, e.g. (123) 456-7890 or 123-456-7890".