home / skills / aidotnet / moyucode / regex-tester

regex-tester skill

/skills/tools/regex-tester

This skill helps you test and debug regular expressions with match highlighting and capture groups, plus a library of common patterns.

npx playbooks add skill aidotnet/moyucode --skill regex-tester

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
977 B
---
name: regex-tester
description: 测试和调试正则表达式,支持匹配高亮、捕获组和常用模式库。
metadata:
  short-description: 测试正则表达式
source:
  repository: https://github.com/python/cpython
  license: PSF
---

# Regex Tester Tool

## Description
Test and debug regular expressions with match highlighting, capture group extraction, and a library of common patterns.

## Trigger
- `/regex` command
- User needs to test regex
- User wants pattern matching help

## Usage

```bash
# Test pattern
python scripts/regex_tester.py "\\d+" "abc123def456"

# Show capture groups
python scripts/regex_tester.py "(\\w+)@(\\w+)" "user@domain" --groups

# Find all matches
python scripts/regex_tester.py "\\b\\w{4}\\b" "The quick brown fox" --all

# Use common pattern
python scripts/regex_tester.py --pattern email "Contact: [email protected]"
```

## Tags
`regex`, `pattern`, `match`, `test`, `text`

## Compatibility
- Codex: ✅
- Claude Code: ✅

Overview

This skill lets you test and debug regular expressions interactively, with match highlighting, capture group extraction, and a library of common patterns. It focuses on fast feedback so you can validate patterns, inspect groups, and iterate quickly. The tool supports finding all matches and applying named or built-in patterns for common use cases.

How this skill works

Provide a regex and an input string; the tool runs the pattern against the text and returns highlighted matches plus details for each capture group. Options let you list all matches, show group contents, and choose a common pattern from the built-in library (email, URL, digits, etc.). Results include match spans and extracted text to help diagnose why a pattern does or does not match.

When to use it

  • Validating a new regex before adding it to production code
  • Debugging why a capture group returns empty or unexpected values
  • Searching a text sample for all occurrences of a pattern
  • Quickly applying common patterns (email, URL, IP) without writing them from scratch
  • Learning regex behavior by inspecting matches and spans

Best practices

  • Start with a minimal pattern and expand once matches behave as expected
  • Use the capture group view to confirm group boundaries and contents
  • Test edge cases and multiline inputs to ensure anchors and flags work
  • Prefer explicit character classes and quantifiers to avoid catastrophic backtracking
  • Select a common built-in pattern when available to reduce mistakes

Example use cases

  • Highlight all 4-letter words in a sentence to verify boundary anchors
  • Extract username and domain from email strings using capture groups
  • Find every sequence of digits in log entries for downstream processing
  • Validate that a user-supplied pattern matches only intended formats
  • Swap between a custom pattern and a built-in email pattern to compare results

FAQ

Can I see all capture groups for each match?

Yes — enable the groups option to list each capture group's text and span for every match.

Does the tool support finding all matches, not just the first?

Yes — use the find-all option to return every match instance with highlights and group data.