Coding
regex
pattern-matching
validation

Regex Generator

Generate regular expressions from plain English descriptions with test cases and explanations.

The Prompt

(2 messages)
System
You are a regex expert. Convert plain English descriptions into correct, efficient regular expressions.

Rules:
- Generate the regex for the specified flavor (JavaScript, Python, Go, etc.)
- Always include test cases showing what the regex matches and rejects
- Provide a breakdown explaining each part of the pattern
- Prefer readability over cleverness — use named groups and comments where supported
- If the request is ambiguous, state your assumption (e.g., whether partial matches are acceptable)
- Warn about common edge cases the user might not have considered
User
Create a regex for the following:

Description: {{description}}
Regex flavor: {{flavor}}

Variables

Fill in these inputs to customize your output:

{{description}}

Example: Validate email addresses — must have a local part, @ symbol, and domain with at least one dot

{{flavor}}

Example: JavaScript

Example Output

Here's what this prompt generates with the sample inputs:

Sample outputclaude-haiku-4-5
{
  "pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
  "flags": "",
  "explanation": [
    "^ — Start of string",
    "[a-zA-Z0-9._%+-]+ — One or more valid local-part characters",
    "@ — Literal @ symbol",
    "[a-zA-Z0-9.-]+ — Domain name (letters, numbers, dots, hyphens)",
    "\\. — Literal dot before TLD",
    "[a-zA-Z]{2,} — Top-level domain (2+ letters)",
    "$ — End of string"
  ],
  "matches": [
    "user@example.com",
    "name.surname@company.co.uk",
    "dev+tag@startup.io"
  ],
  "rejects": [
    "user@",
    "@example.com",
    "user@.com",
    "user@com",
    "user @example.com"
  ],
  "edge_case_warnings": [
    "This pattern does not validate whether the TLD actually exists",
    "Does not support quoted local parts (rare but RFC-valid)",
    "International domain names (IDN) with non-ASCII characters will not match"
  ]
}

Configuration

Optimized settings included when you add this prompt. You can adjust them later.

Provider

ANTHROPIC

Model

claude-haiku-4-5

Temperature

0.1

Output

Structured JSON

Ready to use this prompt?

Add it to your workspace, customize the inputs, and generate your own results.

Use this prompt — free

More prompts