validation
IPv6 Address Regex Pattern
Validates a full IPv6 address (8 groups of 1-4 hex digits separated by colons). Does NOT match the shortened `::` form — for those, use two patterns (with-shortening and without) as an alternation.
/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/ What each part matches
[0-9a-fA-F]{1,4} — one hex group (1 to 4 hex digits): — literal colon{7} — seven of 'hex-group + colon'[0-9a-fA-F]{1,4}$ — final 8th hex group, no trailing colon✓ These match
- 2001:0db8:85a3:0000:0000:8a2e:0370:7334
- fe80:0000:0000:0000:0202:b3ff:fe1e:8329
✗ These don't
- 2001:db8::1
- 192.168.1.1
- gggg:::0000:0000:0000:0000:0000:0001
Use in your code
JavaScript
const re = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
re.test(input); // → true or false Python
import re
re.fullmatch(r"^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$", input) PHP (PCRE)
preg_match('/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/', $input); Go
re := regexp.MustCompile(`^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$`)
re.MatchString(input) FAQ
Does this ipv6 address regex work in JavaScript?
Yes. Every pattern in the Utilko regex library is tested to work in JavaScript RegExp, PCRE (PHP, Nginx), and Python `re`. Where flavor matters (lookbehind, named groups), the pattern page flags it.
How do I use this pattern?
Copy the pattern from the code block above. In JavaScript:
new RegExp('^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$') or literal /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/. Or click "Try in regex tester" to open it pre-loaded in Utilko's browser-based regex tester.Should I use this for security-critical validation?
Client-side regex is fine for UX (immediate feedback on a form). For anything security-critical — payments, auth, data integrity — always re-validate server-side using the same pattern PLUS domain-specific checks (Luhn checksum for cards, actual email delivery test, DNS resolution for domains).