Regex Explainer
Token-by-token breakdown with examples + pitfalls per token, SVG railroad diagram, 80-entry pattern library (email / URL / IPv4 / UUID / credit card etc.), linter for catastrophic backtracking and common mistakes, cross-flavor converter (JS / PCRE / Python / Java / .NET / Ruby / Go / POSIX).
Pattern
Type or paste a regex. Toggle flags below. Hover any token in the highlighted view to see what it does.
Token breakdown
Each piece of the pattern in order, in plain English.
(?<year>\d{4})Type: Named groupNamed capturing group "year" (#1). Accessible via match.groups.year.
Matches
- · Whatever the inner pattern matches
Does NOT match
- · Anything that fails the inner pattern
\d{4}Type: Predefined classMatches any digit (0–9). Matches the previous element exactly 4 time(s).
Matches
- · 0
- · 5
- · 9
- · Exactly 4 repetitions
Does NOT match
- · a
- · -
- ·
- · Fewer or more than the required count
-Type: LiteralLiteral character — matches the character "-" exactly.
Matches
- · -
Does NOT match
- · Any other character
(?<month>\d{2})Type: Named groupNamed capturing group "month" (#2). Accessible via match.groups.month.
Matches
- · Whatever the inner pattern matches
Does NOT match
- · Anything that fails the inner pattern
\d{2}Type: Predefined classMatches any digit (0–9). Matches the previous element exactly 2 time(s).
Matches
- · 0
- · 5
- · 9
- · Exactly 2 repetitions
Does NOT match
- · a
- · -
- ·
- · Fewer or more than the required count
-Type: LiteralLiteral character — matches the character "-" exactly.
Matches
- · -
Does NOT match
- · Any other character
(?<day>\d{2})Type: Named groupNamed capturing group "day" (#3). Accessible via match.groups.day.
Matches
- · Whatever the inner pattern matches
Does NOT match
- · Anything that fails the inner pattern
\d{2}Type: Predefined classMatches any digit (0–9). Matches the previous element exactly 2 time(s).
Matches
- · 0
- · 5
- · 9
- · Exactly 2 repetitions
Does NOT match
- · a
- · -
- ·
- · Fewer or more than the required count
Railroad diagram
A visual map of the pattern. Click a segment to scroll to its card.
Color-coded by token type
Detected features
High-level summary of what the pattern uses.
Linter
Heuristics that catch common regex mistakes and footguns.
Looks clean — no warnings.
Optimize / simplify
Suggestions to make the pattern shorter, faster, or more readable.
Test against text
Paste sample text. Matches highlight live with capture-group colours.
Use $1, $2, $<name> tokens. Leave blank to skip replacement.
Preview
Release 02/05/2026 Patch 15/06/2026 Kickoff 22/07/2026
3 match(es)
2026-05-02Index: 8–18$1=2026$2=05$3=02year=2026month=05day=022026-06-15Index: 25–35$1=2026$2=06$3=15year=2026month=06day=152026-07-22Index: 44–54$1=2026$2=07$3=22year=2026month=07day=22Pattern library
Curated patterns — click to load into the explainer.
Validation
Email (RFC-lite)
^[^\s@]+@[^\s@]+\.[^\s@]+$
URL (http/https)
^https?:\/\/[^\s/$.?#].[^\s]*$
URL (any scheme)
^[a-z][a-z0-9+.-]*:\/\/\S+$
IPv4
^(?:25[0-5]|2[0-4]\d|[01]?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)){3}$
IPv6
^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$
UUID v4
^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
UUID (any version)
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
ISBN-10
^(?:\d[\ |-]?){9}[\dXx]$
ISBN-13
^97[89][\ |-]?(?:\d[\ |-]?){9}\d$
Credit card (Luhn-shaped)
^(?:\d[ -]?){13,19}$
Visa
^4\d{12}(?:\d{3})?$
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
^3[47]\d{13}$
Phone (E.164)
^\+[1-9]\d{1,14}$
Phone (US)
^(?:\+?1[\s.-]?)?\(?[2-9]\d{2}\)?[\s.-]?\d{3}[\s.-]?\d{4}$
Hex color
^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$
Date ISO 8601
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$
Date US
^(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\d{4}$
Date EU
^(?:0[1-9]|[12]\d|3[01])\.(?:0[1-9]|1[0-2])\.\d{4}$
Time (24h HH:MM)
^(?:[01]\d|2[0-3]):[0-5]\d$
Time (HH:MM:SS)
^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$
Postal code (US ZIP)
^\d{5}(?:-\d{4})?$
Postal code (UK)
^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$
Postal code (CA)
^[ABCEGHJ-NPRSTVXY]\d[A-Z] ?\d[A-Z]\d$
MAC address
^(?:[0-9A-F]{2}[:-]){5}[0-9A-F]{2}$
Slug
^[a-z0-9]+(?:-[a-z0-9]+)*$
Strong password
^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[^A-Za-z0-9]).{8,}$
Username (3-20 alnum + _)
^[A-Za-z0-9_]{3,20}$
Web
URL parts (named)
^(?<scheme>https?):\/\/(?<host>[^\/?#]+)(?<path>\/[^?#]*)?(?:\?(?<query>[^#]*))?(?:#(?<hash>.*))?$
Query string param
[?&]([^=&]+)=([^&]*)
Anchor links
#[A-Za-z0-9-_]+
Domain (no scheme)
^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$
Subdomain
^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.){2,}[a-z]{2,}$
HTML/Markdown
HTML tag
<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s[^>]*)?>
HTML attribute
([a-zA-Z-]+)\s*=\s*"([^"]*)"
Markdown heading
^(#{1,6})\s+(.+)$
Markdown link
\[([^\]]+)\]\(([^)]+)\)
Markdown image
!\[([^\]]*)\]\(([^)]+)\)
HTML comment
<!--[\s\S]*?-->
Programming
Identifier (C-style)
^[A-Za-z_][A-Za-z0-9_]*$
Function declaration
function\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*\(
Arrow function
(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*\(?[^)]*\)?\s*=>
Line comment (//)
\/\/.*$
Block comment
\/\*[\s\S]*?\*\/
Double-quoted string
"(?:[^"\\]|\\.)*"
Single-quoted string
'(?:[^'\\]|\\.)*'
Import statement
^import\s+(?:[^"';]+\s+from\s+)?["']([^"']+)["'];?$
TODO marker
\b(?:TODO|FIXME|HACK|XXX|NOTE)\b:?\s*(.*)$
Data
CSV row
(?:^|,)("(?:[^"]|"")*"|[^",]*)
JSON value (rough)
"(?:[^"\\]|\\.)*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null
key=value pair
([A-Za-z_][A-Za-z0-9_]*)=([^\s]+)
Semantic version
^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+([0-9A-Za-z.-]+))?$
Base64
^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$
Number with separators
^-?\d{1,3}(?:,\d{3})*(?:\.\d+)?$
Money amount
^[$€£¥]?\s?\d{1,3}(?:[,.]\d{3})*(?:[,.]\d{2})?$
Discord/Roblox
Discord ID (snowflake)
^\d{17,20}$
Discord mention
<@!?(\d{17,20})>
Discord channel link
<#(\d{17,20})>
Discord role mention
<@&(\d{17,20})>
Discord custom emoji
<a?:(\w+):(\d{17,20})>
Roblox username
^(?!.*__)[A-Za-z][A-Za-z0-9_]{2,19}$
Minecraft username
^[A-Za-z0-9_]{3,16}$
Minecraft UUID
^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$
Whitespace
Leading whitespace
^\s+
Trailing whitespace
\s+$
Blank line
^\s*$
Multiple spaces
+
Windows line ending
\r\n
Misc
Emoji (rough)
[\u{1F300}-\u{1FAFF}\u{2600}-\u{27BF}]
Roman numeral
^M{0,3}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3})$
GitHub @mention
@([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))
Hex bytes
\b[0-9a-fA-F]{2}\b
MongoDB ObjectId
^[0-9a-f]{24}$
JWT
^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$
Hash (SHA-256 hex)
^[a-f0-9]{64}$
Hash (MD5 hex)
^[a-f0-9]{32}$
Twitter handle
@([A-Za-z0-9_]{1,15})
Hashtag
#([\p{L}\p{N}_]+)
Latitude/longitude
^(-?\d{1,2}(?:\.\d+)?),\s*(-?\d{1,3}(?:\.\d+)?)$
Cross-flavor notes
How the pattern translates to other regex engines and their quirks.