regex-master
БесплатноБез исполняемых скриптовНе проверенUse this skill when building, explaining, or debugging regular expressions for pattern matching, validation, or text extraction. Trigger phrases: 'write a…
от NickCrew★ 76 звёзд на GitHubОб этом скилле
Regex Master
Overview
The Regex Master skill covers building correct, readable, and efficient regular expressions for common text processing tasks. It explains character classes, quantifiers, groups, alternation, anchors, and lookahead/lookbehind assertions. It includes a quick-reference library of battle-tested patterns for emails, URLs, dates, phone numbers, IP addresses, and log lines. Every regex is explained token by token so you understand what it does rather than just copying it.
When to Use
- Validating user input (email, phone, postal code, URL)
- Extracting structured data from unstructured text (logs, documents, HTML attributes)
- Search-and-replace with patterns in code editors or scripts
- Parsing delimited or fixed-format text files
- Filtering or transforming data with
grep,sed,awk, Python, or JavaScript
When NOT to Use
- Parsing HTML or XML (use a DOM parser: BeautifulSoup, DOMParser — regex is unreliable for nested structures)
- Parsing programming languages or complex grammars (use a proper parser/AST)
- Matching natural language semantics (use NLP tools)
- When a simple string split or indexOf is sufficient — don't reach for regex when a simpler tool works
Quick Reference
Building Blocks
| Token | Meaning | Example | Matches |
|---|---|---|---|
. |
Any character except newline | a.c |
abc, a1c, a-c |
\d |
Digit [0-9] |
\d+ |
42, 007 |
\w |
Word char [a-zA-Z0-9_] |
\w+ |
hello, foo_2 |
\s |
Whitespace | \s+ |
space, tab, newline |
\D |
Non-digit | \D |
a, -, |
\W |
Non-word char | \W |
!, @, |
\S |
Non-whitespace | \S+ |
hello, 42 |
^ |
Start of string/line | ^Hello |
Hello world |
$ |
End of string/line | world$ |
Hello world |
\b |
Word boundary | \bcat\b |
the cat sat (not catch) |
[abc] |
Character class | [aeiou] |
any vowel |
[^abc] |
Negated class | [^0-9] |
any non-digit |
[a-z] |
Range | [a-zA-Z] |
any letter |
Quantifiers
| Quantifier | Meaning | Greedy? |
|---|---|---|
* |
0 or more | Yes |
+ |
1 or more | Yes |
? |
0 or 1 (optional) | Yes |
{n} |
Exactly n | Yes |
{n,m} |
Between n and m | Yes |
{n,} |
n or more | Yes |
*? |
0 or more | No (lazy) |
+? |
1 or more | No (lazy) |
Groups & References
| Syntax | Meaning |
|---|---|
(abc) |
Capturing group |
(?:abc) |
Non-capturing group |
(?P<name>abc) |
Named capturing group (Python) |
(?<name>abc) |
Named capturing group (JS/PCRE) |
\1, $1 |
Back-reference to group 1 |
a|b |
Alternation: a or b |
Lookaround
| Syntax | Meaning |
|---|---|
(?=abc) |
Positive lookahead: followed by abc |
(?!abc) |
Negative lookahead: NOT followed by abc |
(?<=abc) |
Positive lookbehind: preceded by abc |
(?<!abc) |
Negative lookbehind: NOT preceded by abc |
Flags
| Flag | Effect |
|---|---|
i / re.IGNORECASE |
Case-insensitive |
m / re.MULTILINE |
^/$ match line boundaries |
s / re.DOTALL |
. matches newlines |
g |
Global — find all matches (JS) |
x / re.VERBOSE |
Allow whitespace/comments in pattern |
Common Patterns Library
| Pattern | Regex |
|---|---|
| Email (simple) | ^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$ |
| URL | https?://[\w.-]+(?:/[\w./?=#&%-]*)? |
| IPv4 | \b(?:\d{1,3}\.){3}\d{1,3}\b |
| Date (YYYY-MM-DD) | \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) |
| Time (HH:MM:SS) | (?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d |
| US Phone | \+?1?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4} |
| ZIP code (US) | \d{5}(?:-\d{4})? |
| Credit card | \b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b |
| Hex color | #(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b |
| UUID | [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} |
| Semantic version | \d+\.\d+\.\d+(?:-[\w.]+)?(?:\+[\w.]+)? |
| HTML tag (simple) | <([a-z][a-z0-9]*)\b[^>]*>(.*?)</\1> |
| Slug | ^[a-z0-9]+(?:-[a-z0-9]+)*$ |
Instructions
Define what to match precisely in plain English first
- What does a valid match look like? (examples)
- What should NOT match? (counter-examples)
- Where in the string must it appear? (anywhere, start, full string)
Build the regex incrementally
- Start with the simplest pattern that matches one known good example.
- Add character classes, quantifiers, and anchors one at a time.
- Test after each addition against both positive and negative examples.
Anchor appropriately
- Use
^...$for full-string validation (email, phone, slug). - Omit anchors for searching within a larger text.
- Use
\bfor word-boundary matching to avoid partial matches.
- Use
Choose capturing vs. non-capturing groups
- Use
(?:...)for grouping without capturing when you don't need the group's value. - Use named groups
(?P<year>\d{4})for readability and reliable
- Use
Установить regex-master в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл regex-master?
Use this skill when building, explaining, or debugging regular expressions for pattern matching, validation, or text extraction. Trigger phrases: 'write a regex', 'match this pattern', 'validate this format', 'extract from text'. Not for natural language parsing or full grammar parsing (use a parser instead).
Как установить скилл regex-master?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл regex-master запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic