bug-ops/zeph/regex
Claude Code and agent skill by bug-ops/zeph
- community
Checking that the SKILL.md file is still in the repository.
Write, test, and debug regular expressions for pattern matching, search, and text extraction across programming languages. Use when the user asks to match patterns in text, validate input formats (email, URL, IP, phone, date), extract data with capture groups, build search patterns with lookahead or lookbehind, or understand regex syntax differences between PCRE, POSIX, JavaScript, Python, and Rust flavors.
Install
npx vskill@latest install bug-ops/zeph/regexSKILL.md
Regular Expressions Reference
Quick Reference
| Pattern | Matches | ||
|---|---|---|---|
. | Any character (except newline) | ||
\d | Digit [0-9] | ||
\w | Word character [a-zA-Z0-9_] | ||
\s | Whitespace (space, tab, newline) | ||
\D, \W, \S | Negated versions | ||
^ | Start of line | ||
$ | End of line | ||
\b | Word boundary | ||
* | 0 or more | ||
+ | 1 or more | ||
? | 0 or 1 (optional) | ||
{n} | Exactly n | ||
{n,m} | Between n and m | ||
[abc] | Character class | ||
[^abc] | Negated character class | ||
(...) | Capture group | ||
(?:...) | Non-capturing group | ||
| `a\ | b` | Alternation |
Character Classes
Shorthand Classes
| Class | Equivalent | Matches | |
|---|---|---|---|
\d | [0-9] | Digit | |
\D | [^0-9] | Non-digit | |
\w | [a-zA-Z0-9_] | Word character | |
\W | [^a-zA-Z0-9_] | Non-word character | |
\s | [ \t\n\r\f\v] | Whitespace | |
\S | [^ \t\n\r\f\v] | Non-whitespace | |
\h | [ \t] | Horizontal whitespace (PCRE) | |
\v | [\n\r\f\v] | Vertical whitespace (PCRE) |
POSIX Classes (use inside [...])
| Class | Matches | |
|---|---|---|
[:alpha:] | Letters | |
[:digit:] | Digits | |
[:alnum:] | Letters and digits | |
[:upper:] | Uppercase letters | |
[:lower:] | Lowercase letters | |
[:space:] | Whitespace | |
[:punct:] | Punctuation | |
[:print:] | Printable characters | |
[:graph:] | Visible characters (no space) | |
[:xdigit:] | Hex digits [0-9a-fA-F] |
Usage: [[:alpha:]] (double brackets when inside a character class).
Custom Character Classes
Quantifiers
Greedy (match as much as possible)
| Quantifier | Meaning | |
|---|---|---|
* | 0 or more | |
+ | 1 or more | |
? | 0 or 1 | |
{3} | Exactly 3 | |
{2,5} | 2 to 5 | |
{2,} | 2 or more |
Lazy (match as little as possible)
Add ? after the quantifier:
| Lazy | Meaning | |
|---|---|---|
*? | 0 or more (lazy) | |
+? | 1 or more (lazy) | |
?? | 0 or 1 (lazy) | |
{2,5}? | 2 to 5 (lazy) |
Example difference:
Possessive (no backtracking, PCRE/Java)
Add + after the quantifier: *+, ++, ?+
Possessive quantifiers never give back matched characters, which prevents catastrophic backtracking but may cause the match to fail where greedy would succeed.
Anchors
| Anchor | Matches | |
|---|---|---|
^ | Start of line (or string with \A) | |
$ | End of line (or string with \z / \Z) | |
\b | Word boundary | |
\B | Non-word boundary | |
\A | Start of string (never affected by multiline flag) | |
\z | End of string (absolute) | |
\Z | End of string (allows trailing newline) |
Groups
Capturing Groups
Named Groups
Non-Capturing Groups
Backreferences
Lookaround Assertions
Lookaround matches a position without consuming characters (zero-width).
Lookahead
Lookbehind
Lookbehind restrictions: in most flavors (PCRE, Python, JavaScript), lookbehind must have a fixed length. Variable-length lookbehind is supported in .NET, Java 13+, and Python's regex module.
Practical Examples
Alternation
Flags / Modifiers
| Flag | Name | Effect | |
|---|---|---|---|
i | Case insensitive | a matches A | |
m | Multiline | ^ and $ match line boundaries | |
s | Dotall / single-line | . matches newline | |
x | Extended / verbose | Ignore whitespace and # comments | |
g | Global | Match all occurrences (not all flavors) | |
u | Unicode | Full Unicode matching |
Inline flags (within pattern):
Common Patterns
Email Address (simplified)
URL
IPv4 Address
Strict (0-255 per octet):
IPv6 Address (simplified)
Date (YYYY-MM-DD)
Time (HH:MM:SS, 24h)
Phone Number (US)
Hex Color
Semantic Version
UUID
File Path (Unix)
Whitespace Normalization
Flavor Differences
| Feature | PCRE | JavaScript | Python | Rust | POSIX BRE | POSIX ERE | |
|---|---|---|---|---|---|---|---|
\d | Yes | Yes | Yes | Yes | No | No | |
| Named groups | (?P<n>) | (?<n>) | (?P<n>) | (?P<n>) | No | No | |
| Lookbehind | Fixed | Fixed (ES2018) | Fixed | No | No | No | |
| Backrefs | Yes | Yes | Yes | No | \1 | No | |
Possessive ++ | Yes | No | No | No | No | No | |
Atomic (?>) | Yes | No | No | Yes | No | No | |
Unicode \p{L} | Yes | Yes (u flag) | Yes | Yes | No | No | |
\b | Yes | Yes | Yes | Yes | No | No | |
Multiline . | (?s) | s flag | re.DOTALL | (?s) | N/A | N/A |
Key flavor notes
- Rust (`regex` crate): no backreferences, no lookaround (use
fancy-regexfor those). Guaranteed linear time. - JavaScript: lookbehind added in ES2018 (modern browsers). No possessive quantifiers or atomic groups.
- Python:
remodule has fixed-length lookbehind.regexmodule (third-party) supports variable-length lookbehind. - POSIX BRE: requires escaping
(,),{,}— they are literal without backslash. Used bygrep(default),sed. - POSIX ERE:
(,),{,}are special without backslash. Used bygrep -E,awk,sed -E.
Testing Strategies
Performance Tips
- Avoid catastrophic backtracking:
(a+)+bon "aaaaaac" causes exponential time - Use possessive quantifiers (
++) or atomic groups ((?>...)) when available - Anchored patterns (
^...$) are faster than unanchored - Character classes
[aeiou]are faster than alternationa|e|i|o|u - Avoid
.*at the start of a pattern; use a more specific prefix - Pre-compile regex objects when matching in a loop (all languages)
- Use non-capturing groups
(?:...)when you do not need the captured text - Rust's
regexcrate guarantees O(n) matching; if you need backreferences, usefancy-regexbut be aware of potential exponential time
Important Notes
- Always use raw strings in programming languages to avoid double-escaping: Python
r"\d+", Rustr"\d+" \bmatches a position between a word character and a non-word character, not a character itself.does not match\nby default; enable dotall/single-line mode (sflag) if needed^and$match start/end of string by default; enable multiline mode (mflag) for line boundaries- In character classes, most special characters lose their meaning:
[.]matches a literal dot - Hyphen in character class must be first, last, or escaped:
[a-z]is a range,[-az]includes literal- - Caret
^negates a character class only when it is the first character:[^abc] - Always test regex against edge cases: empty strings, very long inputs, Unicode, special characters
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.zeph/skills/regex/SKILL.md
Popularity
- Repository stars
- 65
- Repository forks
- 7
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/bug-ops/zeph/regex)