Network & Web · In-Browser Regular Expression Lab
IPv6 Regex — Validate Hexadecimal IPv6 Addresses & Compactions
Matches standard 8-group IPv6 addresses as well as compressed double-colon (::) formats.
Flags:
//i
Match Found
Load Sample:
Match Inspection & Details1 match
Match #1:2001:0db8:85a3:0000:0000:8a2e:0370:7334
Test Samples Verification Matrix
Expected Valid Samples (Should Match)
2001:0db8:85a3:0000:0000:8a2e:0370:7334 Pass
fe80:0000:0000:0000:0204:61ff:fe9d:f156 Pass
::1 Pass
Expected Invalid Samples (Must Reject)
1200::AB00:1234::2552:7777:1313 Rejected (Pass)
192.168.1.1 Rejected (Pass)
gggg:1234::1 Rejected (Pass)
Code Implementation Generator
// JavaScript / TypeScript (ES6+)
const pattern = /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::1$|^::$/i;
const text = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
const isMatch = pattern.test(text);
console.log("Is Match:", isMatch);
if (isMatch) {
const matches = text.match(pattern);
console.log("Matches:", matches);
}Regular Expression Token Breakdown
Matches 8 hex hextets separated by colons, including common loopback and unassigned forms. Each component of the regular expression serves a distinct syntactical purpose as mapped below:
| Token Pattern | Name / Component | Function & Rule |
|---|---|---|
| [0-9a-fA-F]{1,4} | Hextet | Matches 1 to 4 hexadecimal digits. |
| : | Colon | Delimiter separating hextets. |
| {7} | Repeat 7 times | Requires first seven groups with colons. |
Frequently Asked Questions
Does this match full IPv6 RFC specification?
Related Regular Expressions
Browse All 40 PatternsNetwork & Web
IPv4 Address Validator
Strictly validates IPv4 addresses ensuring each octet is within the valid 0 to 255 numerical range.
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/Test regex
Network & Web
MAC Address Matcher
Matches 6-byte IEEE 802 Media Access Control (MAC) hardware addresses with colons or hyphens.
/^(?:[0-9A-Fa-f]{2}[:-]){5}(?:[0-9A-Fa-f]{2})$/Test regex
Authentication & Security
JSON Web Token (JWT)
Validates standard 3-part JSON Web Tokens (Header.Payload.Signature) in Base64URL encoding.
/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/Test regex