Common use cases
- ✓Network configuration validation
- ✓Infrastructure inventory checks
- ✓Log-field prevalidation
Test common full and compressed IPv6 address forms, including the double-colon abbreviation used to collapse consecutive zero groups. IPv6 has substantially more valid textual forms than IPv4, so this page also explains when a platform IP parser is a better production choice.
^(?:(?:[0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|(?:[0-9a-f]{1,4}:){1,7}:|(?:[0-9a-f]{1,4}:){1,6}:[0-9a-f]{1,4}|(?:[0-9a-f]{1,4}:){1,5}(?::[0-9a-f]{1,4}){1,2}|(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,3}|(?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,4}|(?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,5}|[0-9a-f]{1,4}:(?:(?::[0-9a-f]{1,4}){1,6})|:(?:(?::[0-9a-f]{1,4}){1,7}|:))$Flags: i
Enter one value per line. Each line is tested against the whole-string pattern using the browser JavaScript RegExp engine.
2001:db8:85a3:0:0:8a2e:370:73342001:db8::1::1::2001:db8:::12001:db8:zzzz::12001:db8:1:2:3:4:5:6:72001:db8IPv6 validation requires accounting for both eight-group full notation and multiple legal placements of the :: compression marker. A short “hex groups separated by colons” regex usually rejects valid compressed addresses or accepts too many groups.
2001:db8:85a3:0:0:8a2e:370:73342001:db8::1::1::2001:db8:::12001:db8:zzzz::12001:db8:1:2:3:4:5:6:72001:db8IPv6 allows eight hexadecimal groups plus a double-colon abbreviation that can replace one or more consecutive zero groups in several positions. Enumerating those valid shapes makes the expression longer.
Yes. Loopback shorthand and the all-zero unspecified-address shorthand are included.
Regex can be useful for front-end checks and data screening, but a purpose-built IP parser is preferable when you need normalization, address-family handling, reserved-range classification, zone identifiers, or IPv4-embedded forms.
Move from a live JavaScript regex test to capture-group inspection, flag behavior, literal escaping, focused pattern references, and debugging guides without treating each regex task as an isolated page.