Creates and thoroughly explains regular expressions with breakdowns, test cases, and language-specific implementations.
You are a regex expert who creates and explains regular expressions. Help me create a regex for this pattern.
What I want to match: [DESCRIBE IN PLAIN ENGLISH]
Examples that SHOULD match:
[LIST EXAMPLES]
Examples that should NOT match:
[LIST NON-EXAMPLES]
Language/Engine: [JAVASCRIPT / PYTHON / PCRE / OTHER]
Performance needs: [CASUAL / HIGH-PERFORMANCE]
Provide:
**Regex Pattern**
```regex
[PATTERN]
```
**Breakdown Explanation**
```
^ - Start of string
(?:...) - Non-capturing group
[a-z] - Character class
\d{3} - Exactly 3 digits
```
**Visual Diagram**
```
[ASCII visualization of the pattern]
```
**Test Cases**
| Input | Expected | Explanation |
|-------|----------|-------------|
| "abc" | Match | Because... |
| "xyz" | No match | Because... |
**Language-Specific Code**
```javascript
const regex = /pattern/flags;
const match = regex.test(string);
const groups = string.match(regex);
```
```python
import re
pattern = re.compile(r'pattern')
match = pattern.match(string)
groups = pattern.findall(string)
```
**Capture Groups**
- Group 0 (full match): [description]
- Group 1: [what it captures]
- Named groups if applicable
**Performance Considerations**
- Potential catastrophic backtracking
- Optimization suggestions
- When to use possessive quantifiers
**Edge Cases Handled**
- [Edge case 1]
- [Edge case 2]
**Alternative Patterns**
- Simpler version (if trade-offs acceptable)
- More permissive version
- Stricter version
**Common Pitfalls**
- [Warning about common mistakes]You are a regex expert who creates and explains regular expressions. Help me create a regex for this pattern.
What I want to match: [DESCRIBE IN PLAIN ENGLISH]
Examples that SHOULD match:
[LIST EXAMPLES]
Examples that should NOT match:
[LIST NON-EXAMPLES]
Language/Engine: [JAVASCRIPT / PYTHON / PCRE / OTHER]
Performance needs: [CASUAL / HIGH-PERFORMANCE]
Provide:
**Regex Pattern**
```regex
[PATTERN]
```
**Breakdown Explanation**
```
^ - Start of string
(?:...) - Non-capturing group
[a-z] - Character class
\d{3} - Exactly 3 digits
```
**Visual Diagram**
```
[ASCII visualization of the pattern]
```
**Test Cases**
| Input | Expected | Explanation |
|-------|----------|-------------|
| "abc" | Match | Because... |
| "xyz" | No match | Because... |
**Language-Specific Code**
```javascript
const regex = /pattern/flags;
const match = regex.test(string);
const groups = string.match(regex);
```
```python
import re
pattern = re.compile(r'pattern')
match = pattern.match(string)
groups = pattern.findall(string)
```
**Capture Groups**
- Group 0 (full match): [description]
- Group 1: [what it captures]
- Named groups if applicable
**Performance Considerations**
- Potential catastrophic backtracking
- Optimization suggestions
- When to use possessive quantifiers
**Edge Cases Handled**
- [Edge case 1]
- [Edge case 2]
**Alternative Patterns**
- Simpler version (if trade-offs acceptable)
- More permissive version
- Stricter version
**Common Pitfalls**
- [Warning about common mistakes]This prompt is released under CC0 (Public Domain). You are free to use it for any purpose without attribution.
Explore similar prompts based on category and tags
Creates comprehensive Architecture Decision Records with options analysis, decision matrices, and consequence documentation.
Conducts thorough code reviews covering security, performance, maintainability, and best practices with specific fix suggestions.
Analyzes complex error stack traces to identify root causes and provide specific code fixes.
Identifies security vulnerabilities with fixes, OWASP analysis, and comprehensive hardening recommendations.