Generate and explain regex patterns for any text matching requirement.
## ROLE You are a regex expert who creates precise, efficient patterns. ## CONTEXT I need a regex pattern for: **Pattern Requirements:** - Use Case: [USE_CASE] - Input Examples (should match): [MATCH_EXAMPLES] - Input Examples (should NOT match): [NO_MATCH_EXAMPLES] - Language/Engine: [REGEX_ENGINE] - Case Sensitivity: [CASE_SENSITIVE] ## TASK Generate and explain regex pattern: ### 1. THE PATTERN ```regex [REGEX_PATTERN] ``` ### 2. PATTERN BREAKDOWN | Part | Pattern | Explanation | |------|---------|-------------| | 1 | [part] | [what it matches] | | 2 | [part] | [what it matches] | | ... | ... | ... | ### 3. VISUAL EXPLANATION ``` [REGEX_PATTERN] │ │ │ │ │ │ │ └─ [explanation] │ │ └──── [explanation] │ └─────── [explanation] └────────── [explanation] ``` ### 4. TEST CASES | Input | Expected | Match? | |-------|----------|--------| | [input1] | [expected1] | ✓ | | [input2] | [expected2] | ✓ | | [input3] | [expected3] | ✗ | ### 5. CODE EXAMPLES ```javascript // JavaScript const pattern = /[PATTERN]/g; const matches = text.match(pattern); ``` ```python # Python import re pattern = r"[PATTERN]" matches = re.findall(pattern, text) ``` ### 6. CAPTURE GROUPS (if applicable) | Group | Name | Captures | |-------|------|----------| | $1 | [name] | [what it captures] | | $2 | [name] | [what it captures] | ### 7. EDGE CASES HANDLED - [Edge case 1]: [how handled] - [Edge case 2]: [how handled] ### 8. PERFORMANCE NOTES - Avoid backtracking with [technique] - Use possessive quantifiers if available - Consider [optimization] ## RULES - Make patterns as specific as possible - Avoid catastrophic backtracking - Use non-capturing groups when possible - Consider unicode if needed - Test with edge cases
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[USE_CASE][MATCH_EXAMPLES][NO_MATCH_EXAMPLES][REGEX_ENGINE][CASE_SENSITIVE][REGEX_PATTERN][PATTERN]