regex-mastery
Use this skill when writing regular expressions, debugging pattern matching, optimizing regex performance, or implementing text validation. Triggers on regex, regular expressions, pattern matching, lookahead, lookbehind, named groups, capture groups, backreferences, and any task requiring text pattern matching.
devtools regexpatternstext-processingvalidationmatchingWhat is regex-mastery?
Use this skill when writing regular expressions, debugging pattern matching, optimizing regex performance, or implementing text validation. Triggers on regex, regular expressions, pattern matching, lookahead, lookbehind, named groups, capture groups, backreferences, and any task requiring text pattern matching.
regex-mastery
regex-mastery is a production-ready AI agent skill for claude-code, gemini-cli, openai-codex. Writing regular expressions, debugging pattern matching, optimizing regex performance, or implementing text validation.
Quick Facts
| Field | Value |
|---|---|
| Category | devtools |
| Version | 0.1.0 |
| Platforms | claude-code, gemini-cli, openai-codex |
| License | MIT |
How to Install
- Make sure you have Node.js installed on your machine.
- Run the following command in your terminal:
npx skills add AbsolutelySkilled/AbsolutelySkilled --skill regex-mastery- The regex-mastery skill is now available in your AI coding agent (Claude Code, Gemini CLI, OpenAI Codex, etc.).
Overview
Regular expressions are a compact language for describing text patterns, built into virtually every programming language and text processing tool. They power input validation, log parsing, data extraction, search-and-replace, and tokenization. Used well, a single regex can replace dozens of lines of string manipulation code. Used poorly, they become unreadable traps and can grind a server to a halt via catastrophic backtracking.
Tags
regex patterns text-processing validation matching
Platforms
- claude-code
- gemini-cli
- openai-codex
Related Skills
Pair regex-mastery with these complementary skills:
Frequently Asked Questions
What is regex-mastery?
Use this skill when writing regular expressions, debugging pattern matching, optimizing regex performance, or implementing text validation. Triggers on regex, regular expressions, pattern matching, lookahead, lookbehind, named groups, capture groups, backreferences, and any task requiring text pattern matching.
How do I install regex-mastery?
Run npx skills add AbsolutelySkilled/AbsolutelySkilled --skill regex-mastery in your terminal. The skill will be immediately available in your AI coding agent.
What AI agents support regex-mastery?
This skill works with claude-code, gemini-cli, openai-codex. Install it once and use it across any supported AI coding agent.
Maintainers
Generated from AbsolutelySkilled
SKILL.md
Regex Mastery
Regular expressions are a compact language for describing text patterns, built into virtually every programming language and text processing tool. They power input validation, log parsing, data extraction, search-and-replace, and tokenization. Used well, a single regex can replace dozens of lines of string manipulation code. Used poorly, they become unreadable traps and can grind a server to a halt via catastrophic backtracking.
When to use this skill
Trigger this skill when the user:
- Asks to write or explain a regular expression
- Wants to validate input format (email, URL, phone number, date, credit card)
- Needs to extract data from structured or semi-structured text (logs, CSV, HTML)
- Uses regex terminology: lookahead, lookbehind, named group, capture group, backreference
- Wants to debug a pattern that isn't matching as expected
- Asks about regex flags (
i,g,m,s,u,x) - Needs to replace text using capture groups or back-references
Do NOT trigger this skill for:
- Full HTML/XML parsing (use a proper parser like DOMParser or BeautifulSoup instead)
- Complex natural language processing where ML models are a better fit
Key principles
Readability over cleverness - A regex that nobody can maintain is worse than a slightly longer explicit approach. Break complex patterns into commented steps or use the verbose (
x) flag where supported. A named group costs nothing but pays dividends every time someone reads the pattern.Use named capture groups -
(?<year>\d{4})is self-documenting and immune to positional breakage when the pattern changes. Always prefer named groups over numbered groups for any regex that will be read or maintained by humans.Test edge cases relentlessly - Empty string, Unicode characters, very long input, malformed-but-close input (e.g.,
foo@barfor email), and adversarial input designed to trigger backtracking. A regex that passes your happy path but fails on a Unicode em-dash will cause production incidents.Avoid catastrophic backtracking - Nested quantifiers (
(a+)+) and overlapping alternatives ((a|ab)+) cause exponential backtracking on non-matching input. Use atomic groups or possessive quantifiers where available, or restructure alternation so choices are mutually exclusive.Use the right tool - Regex is not always the answer. Parsing emails to RFC 5321 compliance requires a full parser. Parsing JSON, HTML, or XML requires a DOM/SAX parser. If a regex exceeds ~80 characters or requires >2 levels of nesting, pause and ask whether a small state machine or parser would be clearer.
Core concepts
Greedy vs lazy quantifiers - *, +, ?, and {n,m} are greedy by default:
they match as much as possible while still allowing the overall pattern to succeed.
Add ? to make them lazy (*?, +?): they match as little as possible. In
<.+> matching <b>text</b>, greedy gives the whole string; lazy <.+?> gives
just <b>.
Backtracking engine - Most regex engines (NFA-based: JS, Python, Java, .NET, PCRE) work by trying a path and backing up when it fails. The cost of a failed match can be exponential if quantifiers are nested and the pattern allows too many overlapping interpretations. POSIX (DFA-based) engines don't backtrack but lack lookaheads and backreferences.
Character classes - [abc] matches any one of a, b, c. [^abc] is the negation.
Shorthand classes: \d (digit), \w (word char), \s (whitespace), \D, \W,
\S (their negations). The . metacharacter matches any character except newline
(unless the s/dotall flag is set). Always prefer \d over [0-9] for clarity,
and [^\n] over . when you mean "not newline".
Anchors - ^ and $ match start/end of string (or line with the m flag).
\b is a word boundary (zero-width). \A, \Z are absolute start/end of string
in Python (unaffected by multiline mode). Use anchors aggressively - an unanchored
pattern can match anywhere in the string, which is often not what you want.
Groups and alternation - (abc) is a capturing group; (?:abc) is
non-capturing (slightly faster, doesn't pollute $1/match.groups). Named groups:
(?<name>abc) in JS/Python/PCRE. Alternation a|b is left-to-right and short-circuits
- put the most common or most specific branch first. Backreferences
\1or\k<name>match the same text captured by a group.
Common tasks
Validate an email address (basic)
A practical email regex that catches most invalid formats without attempting full RFC compliance (which would require a 6553-character pattern).
const emailRegex = /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/
function isValidEmail(email) {
return emailRegex.test(email.trim())
}
// Examples
isValidEmail('user@example.com') // true
isValidEmail('user+tag@sub.co.uk') // true
isValidEmail('notanemail') // false
isValidEmail('@nodomain.com') // falseNever use regex alone as the authoritative email validator in security-sensitive code. Always send a confirmation link. The only true validator is delivery.
Validate a URL
const urlRegex = /^https?:\/\/(?:[\w\-]+\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:\/[^\s]*)?$/
function isValidUrl(url) {
try {
new URL(url) // prefer the URL constructor in JS environments
return true
} catch {
return false
}
}Prefer the native
URLconstructor in JS/Node.js over regex for URL validation. It handles edge cases like IPv6, IDN hostnames, and percent-encoded paths correctly.
Validate a phone number (E.164 format)
// E.164: +[country code][subscriber number], 7-15 digits total
const e164Regex = /^\+[1-9]\d{6,14}$/
// North American (NANP) with flexible formatting
const nanpRegex = /^(\+1[-.\s]?)?(\(?\d{3}\)?[-.\s]?)?\d{3}[-.\s]?\d{4}$/
e164Regex.test('+14155552671') // true
e164Regex.test('4155552671') // false (no + prefix)
nanpRegex.test('(415) 555-2671') // true
nanpRegex.test('415.555.2671') // trueExtract data with named capture groups
Named groups make extraction code self-documenting and resilient to group reordering.
const logLineRegex = /^\[(?<timestamp>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\] (?<level>INFO|WARN|ERROR) (?<message>.+)$/m
const line = '[2026-03-14T09:41:00] ERROR Database connection refused'
const match = line.match(logLineRegex)
if (match) {
const { timestamp, level, message } = match.groups
console.log(timestamp) // '2026-03-14T09:41:00'
console.log(level) // 'ERROR'
console.log(message) // 'Database connection refused'
}Use lookahead and lookbehind
Lookarounds are zero-width assertions - they check context without consuming characters.
// Positive lookahead: password must contain a digit
const hasDigit = /(?=.*\d)/
// Negative lookahead: word not followed by "(deprecated)"
const notDeprecated = /\bfoo\b(?!\s*\(deprecated\))/
// Positive lookbehind: price value preceded by $
const priceRegex = /(?<=\$)\d+(?:\.\d{2})?/g
'Total: $49.99 and $5.00'.match(priceRegex) // ['49.99', '5.00']
// Negative lookbehind: "port" not preceded by "trans"
const portNotTransport = /(?<!trans)port/giLookbehind (
(?<=...)and(?<!...)) is supported in V8 (Node.js/Chrome), .NET, and Python 3.1+, but NOT in Safari < 16.4 or older PCRE. Check target environment before using.
Replace with capture groups
Use $1 / $<name> in the replacement string to insert captured text.
// Reformat date from MM/DD/YYYY to YYYY-MM-DD
const date = '03/14/2026'
const reformatted = date.replace(
/^(?<month>\d{2})\/(?<day>\d{2})\/(?<year>\d{4})$/,
'$<year>-$<month>-$<day>'
)
// '2026-03-14'
// Wrap all @mentions in an anchor tag
const text = 'Hello @alice and @bob'
const linked = text.replace(/@(\w+)/g, '<a href="/user/$1">@$1</a>')
// 'Hello <a href="/user/alice">@alice</a> and <a href="/user/bob">@bob</a>'Avoid catastrophic backtracking
The classic trap: alternation inside a repeated group where alternatives overlap.
// DANGEROUS - exponential time on non-matching input
const bad = /^(a+)+$/
bad.test('aaaaaaaaaaaaaaaaaaaaaaab') // hangs
// SAFE - remove the nested quantifier
const good = /^a+$/
good.test('aaaaaaaaaaaaaaaaaaaaaaab') // instant false
// SAFE alternative using atomic-group emulation via possessive quantifier (PCRE)
// In JS, restructure so the branches are mutually exclusive:
const safe = /^(?:a|b)+$/ // fine because a and b can't both match the same charAny time you write
(x+)+,(x|y)+where x and y can match the same char, or deeply nested quantifiers, stop and test with a 30-character non-matching string. If it hangs, restructure.
Parse structured text (log lines)
Use exec in a loop with the g flag to iterate over all matches.
const accessLogRegex = /^(?<ip>\d{1,3}(?:\.\d{1,3}){3}) - - \[(?<time>[^\]]+)\] "(?<method>GET|POST|PUT|DELETE|PATCH) (?<path>[^ ]+) HTTP\/\d\.\d" (?<status>\d{3}) (?<bytes>\d+)/gm
const log = `192.168.1.1 - - [14/Mar/2026:09:41:00 +0000] "GET /api/users HTTP/1.1" 200 1234
10.0.0.2 - - [14/Mar/2026:09:41:01 +0000] "POST /api/login HTTP/1.1" 401 89`
for (const match of log.matchAll(accessLogRegex)) {
const { ip, method, path, status } = match.groups
console.log(`${ip} ${method} ${path} -> ${status}`)
}Use regex with Unicode
JavaScript requires the u flag for correct Unicode handling. The v flag (ES2024)
adds set notation and string properties.
// WITHOUT u flag - counts UTF-16 code units, breaks on emoji
/^.{3}$/.test('a😀b') // false (emoji is 2 code units, pattern sees 4 chars)
// WITH u flag - counts Unicode code points correctly
/^.{3}$/u.test('a😀b') // true
// Match any Unicode letter (requires u or v flag)
const wordChars = /[\p{L}\p{N}_]+/u
// Match emoji
const emoji = /\p{Emoji_Presentation}/gu
// Named Unicode blocks
const cyrillicWord = /^\p{Script=Cyrillic}+$/u
cyrillicWord.test('Привет') // trueAnti-patterns / common mistakes
| Mistake | Why it's wrong | What to do instead |
|---|---|---|
| Unanchored validation pattern | /\d+/ matches the digits inside "abc123def", so test() returns true for invalid input |
Always add ^ and $ anchors for validation patterns |
| Numbered groups in maintained code | match[3] breaks silently when a group is added |
Use named groups: match.groups.year |
Using . to mean "any character" |
. matches everything except newline; bugs appear on multiline input |
Use [\s\S] or set the s (dotAll) flag when newlines should match |
Greedy .* in the middle of a pattern |
"<b>one</b><b>two</b>".match(/<b>.*<\/b>/) returns the whole string |
Use lazy .*? or a negated class [^<]* when bounded by a delimiter |
| Rebuilding the same regex in a loop | new RegExp(pattern) inside a for loop re-compiles on every iteration |
Hoist the regex to a constant outside the loop |
| Parsing HTML/XML with regex | Fails on nested tags, self-closing tags, CDATA, and valid edge cases | Use DOMParser, jsdom, BeautifulSoup, or an XML library |
Gotchas
Lookbehind not supported in Safari < 16.4 -
(?<=...)and(?<!...)are supported in Node.js, Chrome, and .NET but NOT in older Safari (pre-2023 iOS devices). If the regex runs in a browser context, either polyfill or restructure the pattern to avoid lookbehind.Unanchored validation pattern silently passes invalid input -
/\d{4}/matches the digits inside"abc1234xyz", makingtest()returntruefor an invalid value. Always add^and$anchors to any validation pattern.Catastrophic backtracking on adversarial input - Patterns like
(a+)+or(a|ab)+take exponential time on long non-matching strings. Test any pattern with quantifier nesting using a 30-character string that should not match. If it hangs for more than a millisecond, restructure.uflag missing for Unicode input - Without theuflag in JavaScript, emoji and other multi-codepoint characters are counted as two characters by.and{n}. This causes off-by-one failures on strings containing emoji, CJK characters, or diacritics. Always use/pattern/uwhen processing user-supplied text.Regex compiled inside a loop -
new RegExp(pattern)inside aforloop re-compiles the pattern on every iteration, adding overhead proportional to loop count. Hoist regex literals ornew RegExp()calls outside the loop.
References
For ready-to-use patterns across common domains, read:
references/common-patterns.md- 20+ production-ready regex patterns for email, URL, phone, date, IP, UUID, passwords, slugs, semver, credit cards, and more
Only load the references file when you need a specific pattern - it is long and will consume context.
References
common-patterns.md
Common Regex Patterns
Production-ready patterns for frequent use cases. All patterns are in JavaScript
regex literal syntax. Add the u flag when working with Unicode input. Test every
pattern against your specific input format before shipping.
// Basic - catches most invalid formats, avoids RFC rabbit hole
const EMAIL = /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/
// With plus addressing and subdomain support (same pattern, illustrative)
EMAIL.test('user+tag@mail.example.co.uk') // true
EMAIL.test('not@valid') // falseURL
// HTTP/HTTPS with optional port, path, query, and fragment
const URL_HTTP = /^https?:\/\/(?:[\w\-]+\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:\/[^\s]*)?$/
// In Node.js / browser environments, prefer the URL constructor:
function isValidUrl(s) {
try { new URL(s); return true } catch { return false }
}IPv4 Address
// Exact 0-255 per octet
const IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/
IPV4.test('192.168.1.255') // true
IPV4.test('256.1.1.1') // false
IPV4.test('192.168.1') // falseIPv6 Address
// Full 8-group form only - use a library (is-ip, ipaddr.js) for compressed forms
const IPV6_FULL = /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/
// Simplified pattern that also accepts :: compressed notation
const IPV6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})?::(([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})?)$/Phone Numbers
// E.164 international format: +[country][number], 7-15 digits
const PHONE_E164 = /^\+[1-9]\d{6,14}$/
// North American (NANP) - flexible formatting
const PHONE_NANP = /^(\+1[-.\s]?)?(\(?\d{3}\)?[-.\s]?)?\d{3}[-.\s]?\d{4}$/
// Any digits-only string of 7-15 digits (for normalized storage)
const PHONE_DIGITS = /^\d{7,15}$/
PHONE_E164.test('+14155552671') // true
PHONE_NANP.test('(415) 555-2671') // true
PHONE_NANP.test('415.555.2671') // trueDate Formats
// ISO 8601 date: YYYY-MM-DD
const DATE_ISO = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/
// US format: MM/DD/YYYY
const DATE_US = /^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$/
// ISO 8601 datetime with optional timezone
const DATETIME_ISO = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$/
// Note: regex can't validate Feb 30 or leap years - use Date.parse() for thatUUID / GUID
// UUID v4 (most common): 8-4-4-4-12 hex chars, third group starts with 4
const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
// Any valid UUID (v1-v5)
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
UUID_V4.test('550e8400-e29b-41d4-a716-446655440000') // true
UUID_V4.test('not-a-uuid') // falseSemantic Version (semver)
// Core semver: MAJOR.MINOR.PATCH with optional pre-release and build metadata
const SEMVER = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z\-][0-9a-zA-Z\-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z\-][0-9a-zA-Z\-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z\-]+(?:\.[0-9a-zA-Z\-]+)*))?$/
const m = '1.2.3-alpha.1+build.42'.match(SEMVER)
m?.groups // { major: '1', minor: '2', patch: '3', prerelease: 'alpha.1', buildmetadata: 'build.42' }URL Slug
// Lowercase alphanumeric with hyphens, no leading/trailing hyphens
const SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
SLUG.test('my-blog-post-2026') // true
SLUG.test('-starts-with-dash') // false
SLUG.test('has--double-dash') // falsePassword Strength Checks
// At least 8 chars, one uppercase, one lowercase, one digit, one special char
const PASSWORD_STRONG = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=\[\]{}|;':",.<>?]).{8,}$/
// Individual checks (more readable, easier to give specific error messages)
const HAS_LOWERCASE = /[a-z]/
const HAS_UPPERCASE = /[A-Z]/
const HAS_DIGIT = /\d/
const HAS_SPECIAL = /[!@#$%^&*()\-_=+\[\]{}|;':",.<>?\/\\]/
const MIN_LENGTH = /^.{8,}$/Credit Card Numbers (Luhn check still required)
// Visa: starts with 4, 13 or 16 digits
const CC_VISA = /^4[0-9]{12}(?:[0-9]{3})?$/
// Mastercard: starts with 51-55 or 2221-2720, 16 digits
const CC_MASTERCARD = /^(?:5[1-5]\d{2}|222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}$/
// American Express: starts with 34 or 37, 15 digits
const CC_AMEX = /^3[47][0-9]{13}$/
// Generic: 13-19 digits, optional spaces or dashes between groups
const CC_GENERIC = /^\d{4}[\s\-]?\d{4}[\s\-]?\d{4}[\s\-]?\d{1,7}$/
// Always run Luhn algorithm after regex match - regex only checks formatHex Color
// 3 or 6 hex digit color codes (# prefix)
const HEX_COLOR = /^#(?:[0-9a-fA-F]{3}){1,2}$/
// Also matches 4 and 8 digit (with alpha channel, CSS Level 4)
const HEX_COLOR_ALPHA = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/
HEX_COLOR.test('#fff') // true
HEX_COLOR.test('#1a2b3c') // true
HEX_COLOR.test('#xyz') // falsePostal / ZIP Codes
// US ZIP code: 5 digits or ZIP+4
const ZIP_US = /^\d{5}(?:-\d{4})?$/
// UK postcode (simplified)
const POSTCODE_UK = /^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$/i
// Canadian postal code
const POSTAL_CA = /^[ABCEGHJ-NPRSTVXY]\d[A-Z] ?\d[A-Z]\d$/i
ZIP_US.test('90210') // true
ZIP_US.test('90210-1234') // true
ZIP_US.test('9021') // falseHTML/XML Tags (limited - use a parser for full documents)
// Opening tag with optional attributes (simple cases only)
const HTML_OPEN_TAG = /<([a-zA-Z][a-zA-Z0-9]*)\b([^>]*)>/
// Self-closing tag
const HTML_SELF_CLOSING = /<([a-zA-Z][a-zA-Z0-9]*)\b([^>]*)\/>/
// Strip all HTML tags (for plain text extraction - not XSS-safe)
const STRIP_HTML = /<[^>]+>/g
'<b>Hello</b> <i>World</i>'.replace(STRIP_HTML, '') // 'Hello World'
// WARNING: Never use these for security-sensitive HTML sanitization.
// Use DOMPurify or a server-side sanitizer instead.Whitespace and Formatting
// Trim leading/trailing whitespace (prefer String.prototype.trim() instead)
const TRIM = /^\s+|\s+$/g
// Collapse multiple internal whitespace to single space
const NORMALIZE_WHITESPACE = /\s+/g
' hello world '.replace(NORMALIZE_WHITESPACE, ' ').trim() // 'hello world'
// Match blank lines
const BLANK_LINE = /^\s*$/m
// Match Windows-style CRLF line endings
const CRLF = /\r\n/gNumbers
// Integer (positive or negative, no leading zeros)
const INTEGER = /^-?(?:0|[1-9]\d*)$/
// Decimal number (positive or negative, optional decimal part)
const DECIMAL = /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/
// Currency amount (e.g. 1234.56 or 1,234.56)
const CURRENCY = /^\d{1,3}(?:,\d{3})*(?:\.\d{2})?$/
// Hexadecimal number (with optional 0x prefix)
const HEX_NUMBER = /^(?:0[xX])?[0-9a-fA-F]+$/
INTEGER.test('-42') // true
INTEGER.test('007') // false (leading zero)
DECIMAL.test('3.14') // trueDomain Names
// FQDN (fully qualified domain name)
const DOMAIN = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/
// Subdomain extraction from a URL hostname
const SUBDOMAIN_REGEX = /^(?<subdomain>[\w\-]+)\.(?<domain>[\w\-]+\.[\w]{2,})$/
DOMAIN.test('www.example.com') // true
DOMAIN.test('example.com') // true
DOMAIN.test('-invalid.com') // false (leading hyphen)Common Identifiers
// GitHub username: alphanumeric and hyphens, 1-39 chars, no leading/trailing hyphen
const GITHUB_USERNAME = /^[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,37}[a-zA-Z0-9])?$/
// Twitter/X handle (without @)
const TWITTER_HANDLE = /^[a-zA-Z0-9_]{1,15}$/
// npm package name
const NPM_PACKAGE = /^(?:@[a-z0-9\-*~][a-z0-9\-*._~]*\/)?[a-z0-9\-~][a-z0-9\-._~]*$/
// Docker image tag
const DOCKER_TAG = /^[a-zA-Z0-9_\-\.]{1,128}$/ Frequently Asked Questions
What is regex-mastery?
Use this skill when writing regular expressions, debugging pattern matching, optimizing regex performance, or implementing text validation. Triggers on regex, regular expressions, pattern matching, lookahead, lookbehind, named groups, capture groups, backreferences, and any task requiring text pattern matching.
How do I install regex-mastery?
Run npx skills add AbsolutelySkilled/AbsolutelySkilled --skill regex-mastery in your terminal. The skill will be immediately available in your AI coding agent.
What AI agents support regex-mastery?
regex-mastery works with claude-code, gemini-cli, openai-codex. Install it once and use it across any supported AI coding agent.