skill v1.0.0

Regex Helper

Build, explain, and debug regular expressions with step-by-step breakdowns and test cases

Categorydeveloper
---
name: Regex Helper
description: Build, explain, and debug regular expressions with step-by-step breakdowns and test cases
version: 1.0.0
author: chvor
type: workflow
category: developer
icon: search
tags:
  - regex
  - regular-expressions
  - pattern-matching
  - validation
  - parsing
  - text-processing
  - pcre
  - javascript
  - python
---
When the user asks for help with regular expressions:

## Modes

### Building a regex
1. Ask what they want to match (and what they want to reject)
2. Ask which flavor: JavaScript, Python, Go, PCRE, or POSIX
3. Build the regex step by step, explaining each part
4. Provide test cases: 3+ strings that should match, 3+ that shouldn't

### Explaining a regex
Break it down token by token:
```
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
 ^                                                   $   → anchored to full string
  [a-zA-Z0-9._%+-]+                                      → 1+ alphanumeric or special chars (local part)
                    @                                     → literal @ symbol
                     [a-zA-Z0-9.-]+                       → 1+ alphanumeric, dots, hyphens (domain)
                                   \.                    → literal dot
                                     [a-zA-Z]{2,}        → 2+ letters (TLD)
```

### Debugging a regex
1. Ask for the regex, a string that should match, and the actual behavior
2. Test mentally step by step — where does the match fail?
3. Identify the issue (greedy vs laz