💻 Coding & Development

RegEx Generator

📁 Coding & Development 👤 Contributed by @ersinyilmaz 🗓️ Updated
The prompt
Act as a Regular Expression (RegEx) Generator. Your role is to generate regular expressions that match specific patterns in text. You should provide the regular expressions in a format that can be easily copied and pasted into a regex-enabled text editor or programming language. Your task is to: - Generate regex patterns based on the user's specified need, such as matching an email address, phone number, or URL. - Provide only the regex pattern without any explanations or examples. Rules: - Focus solely on the accuracy of the regex pattern. - Do not include explanations or examples of how the regex works. Variables: - ${pattern:email} - Specify the type of pattern to match (e.g., email, phone, URL).

Example outputs

Here is what ChatGPT, Claude, and Gemini typically return for this prompt:

🚀 ChatGPT

Here is a regular expression pattern for matching email addresses: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ This pattern will validate standard email formats with alphanumeric characters, dots, underscores, and hyphens in the local part, followed by the @ symbol and a valid domain structure.

✨ Claude

^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$ Note that email validation via regex has inherent limitations, and this pattern follows RFC 5322 guidelines but may not catch all edge cases. For production use, consider additional validation methods.

💎 Gemini

^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$ This pattern matches most common email formats, including those with dots, underscores, and hyphens. It requires at least a two-character top-level domain.

How to use this prompt

Copy the prompt above or click an "Open in" button to launch it directly in your preferred AI. You can then customize the wording to match your exact use case — for example replacing placeholders like [your topic] with real context.

Which AI model works best

Claude Opus 4 and Sonnet 4.6 generally outperform ChatGPT and Gemini on coding tasks — better reasoning, better at handling long context (full files, multi-file projects), and more honest about uncertainty. ChatGPT is faster for quick snippets; Gemini is best when code involves screenshots or visual context.

How to customize this prompt

Swap the language mentioned in the prompt (Python, JavaScript, etc.) for whichever stack you're on. For debugging or code review, paste your actual code right after the prompt. For generation tasks, specify the framework (React, Vue, Django, FastAPI) and any constraints (max lines, no external libraries, must be async).

Common use cases

  • Writing production code with strict style requirements
  • Reviewing pull requests and catching bugs before merge
  • Converting between languages (Python → TypeScript, for example)
  • Generating unit tests for existing functions
  • Explaining unfamiliar codebases to new team members

Variations

Adapt the tone (more casual, more technical), change the output format (bullet points vs. paragraphs), or add constraints (word limits, target audience).

Related prompts