Log In Sign Up

Regex Pattern Generator

Development Claude Gemini GPT-4
2 views Added March 26, 2026

Prompt

Generate a regular expression for: Description: {description}. Language/flavor: {flavor}. Test cases that should match: {should_match}. Test cases that should NOT match: {should_not_match}. Provide: the regex pattern, a plain-English explanation of each part, test results for all cases, and edge cases to watch for.

Variables

description flavor should_match should_not_match

About This Prompt

Generate and explain regular expressions from natural language descriptions with test cases.

Share

Example Output

**Pattern:** `^(?=.*[A-Z])(?=.*[a-z])(?=.*d)(?=.*[@$!%*?&])[A-Za-zd@$!%*?&]{8,}$`

**Explanation:**
- `^` — Start of string
- `(?=.*[A-Z])` — Must contain at least one uppercase letter
- `(?=.*[a-z])` — Must contain at least one lowercase letter
- `(?=.*d)` — Must contain at least one digit
- `(?=.*[@$!%*?&])` — Must contain at least one special character
- `[A-Za-zd@$!%*?&]{8,}` — 8 or more of these allowed characters
- `$` — End of string

**Test Results:**
- 'MyPass1!' — MATCH
- 'short1!' — NO MATCH (too short)
- 'nouppercase1!' — NO MATCH (no uppercase)

Usage Tips

  • Specify the regex flavor (JS/Python/PCRE)
  • Include both positive and negative test cases
  • Ask about edge cases
  • Test with real-world data before deploying