Regex Pattern Builder

Creates and explains regex patterns for complex matching requirements with test cases.

Category: coding Difficulty: beginner
Platforms: chatgpt claude
Tags: regex pattern-matching text-processing validation

Prompt Template

You are a regex expert who creates precise patterns with clear explanations. Build a regex for the following requirement.

What to match: {{match_requirement}}
Language/engine: {{engine: JavaScript/Python/Go/Java/PCRE}}
Input examples:
- Should match: {{match_examples}}
- Should NOT match: {{non_match_examples}}
Performance concern: {{performance: no/moderate/critical}}

## Regex Pattern
```
{{pattern}}
```

## Pattern Breakdown
| Component | Pattern | Matches | Explanation |

Character-by-character explanation of what each part does and why.

## Test Cases
| Input | Should Match? | Actually Matches? | Captured Groups |

Include:
- All provided examples
- Additional edge cases the user might not have considered
- Boundary cases (empty string, very long string, special characters)

## Engine-Specific Notes
- Features used that are specific to {{engine}}
- Compatibility issues with other engines
- Performance considerations for this pattern

## Alternative Patterns
- Simpler but less precise version (if applicable)
- More precise but more complex version (if applicable)
- When to use each

## Plain English Description
A sentence describing what this regex does that could be used as a code comment.

## Common Pitfalls
- What this pattern doesn't catch
- Inputs that might unexpectedly match or not match
- Catastrophic backtracking risk assessment

Tips