regex-visual-debugger by onewave-ai/claude-skills
npx skills add https://github.com/onewave-ai/claude-skills --skill regex-visual-debugger交互式正则表达式测试、解释和调试工具。
当用户出现以下情况时激活:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 正则表达式分析:`pattern`
## 通俗易懂的解释
此模式匹配 [描述]:
- `^` - 字符串开头
- `[A-Z]` - 一个大写字母
- `\d{3}` - 恰好 3 位数字
- `$` - 字符串结尾
**总体**:匹配类似 "A123"、"Z999" 的字符串
## 可视化结构
^ - 起始锚点
[A-Z] - 字符类(大写字母)
\d{3} - 数字,恰好 3 次
$ - 结束锚点
## 测试结果
### ✅ 匹配
- `A123` → ✓ 完全匹配
- `Z999` → ✓ 完全匹配
### ❌ 不匹配
- `a123` → ✗ 小写 'a' 不匹配 [A-Z]
- `A12` → ✗ 只有 2 位数字(需要 3 位)
- `A1234` → ✗ 数字过多
## 捕获组
1. 组 1:`[captured text]`
2. 组 2:`[captured text]`
## 发现的问题
⚠️ **问题 1**:模式限制过于严格
- **问题**:无法处理小写字母
- **修复**:使用 `[A-Za-z]` 替代 `[A-Z]`
## 改进建议
```regex
# 更灵活的版本
^[A-Za-z]\d{3,5}$
更改:
{3} 改为 {3,5} 以匹配 3-5 位数字A123
Z999
B456
1ABC (以数字开头)
ABCD (没有数字)
A12 (数字太少)
JavaScript:[任何 JS 特定的注意事项] Python:[任何 Python 特定的注意事项]
const pattern = /^[A-Z]\d{3}$/;
const match = str.match(pattern);
import re
pattern = r'^[A-Z]\d{3}$'
match = re.match(pattern, string)
(?:...) 以获得更好的性能用户:"为什么这个正则表达式不匹配电子邮件:\w+@\w+\.\w+?"
响应:分析模式 → 解释它只匹配简单的电子邮件 → 显示测试用例(在 "user+tag@domain.co.uk" 上失败)→ 识别问题(无法处理特殊字符、多个顶级域名)→ 提供改进的模式 → 生成全面的测试用例
用户:"解释这个正则表达式:^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
响应:分解模式(IP 地址匹配器)→ 解释每个组件 → 显示它匹配有效的 IP(每个八位组 0-255)→ 提供测试用例 → 可视化结构
用户:"将这个 Python 正则表达式转换为 JavaScript:(?P<name>\w+)"
响应:识别命名捕获组(Python 特性)→ 转换为 JS 等效形式 → 解释差异 → 显示两个版本的用法示例
每周安装次数
71
代码仓库
GitHub 星标数
75
首次出现时间
2026 年 1 月 24 日
安全审计
安装于
codex60
opencode59
claude-code57
gemini-cli56
cursor56
github-copilot54
Interactive regex testing, explanation, and debugging tool.
Activate when the user:
Analyze the Regex Pattern
Provide Plain English Explanation
Visual Breakdown
Test Against Examples
Identify Common Issues
Generate Test Cases
Suggest Improvements
Convert Between Flavors
# Regex Analysis: `pattern`
## Plain English Explanation
This pattern matches [description]:
- `^` - Start of string
- `[A-Z]` - One uppercase letter
- `\d{3}` - Exactly 3 digits
- `$` - End of string
**Overall**: Matches strings like "A123", "Z999"
## Visual Structure
^ - Start anchor [A-Z] - Character class (uppercase letters) \d{3} - Digit, exactly 3 times $ - End anchor
## Test Results
### ✅ Matches
- `A123` → ✓ Full match
- `Z999` → ✓ Full match
### ❌ No Match
- `a123` → ✗ Lowercase 'a' doesn't match [A-Z]
- `A12` → ✗ Only 2 digits (needs 3)
- `A1234` → ✗ Too many digits
## Capture Groups
1. Group 1: `[captured text]`
2. Group 2: `[captured text]`
## Issues Found
⚠️ **Issue 1**: Pattern is too restrictive
- **Problem**: Doesn't handle lowercase letters
- **Fix**: Use `[A-Za-z]` instead of `[A-Z]`
## Suggested Improvements
```regex
# More flexible version
^[A-Za-z]\d{3,5}$
Changes :
{3} to {3,5} for 3-5 digitsA123
Z999
B456
1ABC (starts with digit)
ABCD (no digits)
A12 (too few digits)
JavaScript : [any JS-specific notes] Python : [any Python-specific notes]
const pattern = /^[A-Z]\d{3}$/;
const match = str.match(pattern);
import re
pattern = r'^[A-Z]\d{3}$'
match = re.match(pattern, string)
Current complexity: O(n)
No backtracking issues
Consider using non-capturing groups: (?:...) for better performance
User: "Why doesn't this regex match emails: \w+@\w+\.\w+?"
Response: Analyze pattern → Explain it matches simple emails only → Show test cases (fails on "user+tag@domain.co.uk") → Identify issues (doesn't handle special chars, multiple TLDs) → Provide improved pattern → Generate comprehensive test cases
User: "Explain this regex: ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
Response: Break down pattern (IP address matcher) → Explain each component → Show it matches valid IPs (0-255 per octet) → Provide test cases → Visualize structure
User: "Convert this Python regex to JavaScript: (?P<name>\w+)"
Response: Identify named capture group (Python feature) → Convert to JS equivalent → Explain differences → Show both versions with usage examples
Weekly Installs
71
Repository
GitHub Stars
75
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex60
opencode59
claude-code57
gemini-cli56
cursor56
github-copilot54
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
120,000 周安装