Regex for IPv6 Address
Regex Pattern
^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$Basic IPv6 address (8 groups of 4 hex digits)
Quick Answer
The regex pattern for ipv6 address is `^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$`. Basic IPv6 address (8 groups of 4 hex digits). This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| 2001:0db8:85a3:0000:0000:8a2e:0370:7334 | ✓ Matches |
| fe80:0000:0000:0000:0204:61ff:fe9d:f156 | ✓ Matches |
| 2001:db8::8a2e:370:7334 | ✗ No match |
| not-an-ipv6 | ✗ No match |
| 192.168.1.1 | ✗ No match |
Code Examples
javascript
const regex = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
const isValid = regex.test(value);python
import re
pattern = r'^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$'
if re.match(pattern, value):
print("valid")ruby
pattern = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/
if value =~ pattern
puts "valid"
endphp
if (preg_match('/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/', $value)) {
echo "valid";
}java
String pattern = "^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$";
boolean isValid = value.matches(pattern);Frequently Asked Questions
Related Regex Patterns
IPv4 Address
Validates a well-formed IPv4 address (0-255 in each octet)
MAC Address
MAC address with colons or dashes as separators
Email Address
Validates a standard email address format
Email (RFC 5322 Compliant)
RFC 5322 compliant email validation with label length limits
URL (HTTP/HTTPS)
Validates HTTP and HTTPS URLs
URL (Any Protocol)
Matches URLs with any protocol (http, https, ftp, ws, etc.)