Regex for IPv6 Address
Validates full IPv6 addresses (eight groups of four hexadecimal digits).
Pattern
/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/i Live Tester
Enter a string to test
Examples
✓ 2001:0db8:85a3:0000:0000:8a2e:0370:7334
✓ fe80:0000:0000:0000:0000:0000:0000:0001
✗ 2001:db8::1
✗ 192.168.1.1
✗ 2001:db8:85a3:0000:0000:8a2e:0370
Pattern Breakdown
([0-9a-fA-F]{1,4}:){7} — seven groups of 1-4 hex digits followed by colon
[0-9a-fA-F]{1,4}$ — final group without trailing colon
Code Snippets
Javascript
const regex = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/i;
regex.test("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); // true Python
import re
pattern = r"^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$"
bool(re.match(pattern, "2001:0db8:85a3:0000:0000:8a2e:0370:7334", re.IGNORECASE)) # True Php
$pattern = '/^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/i';
preg_match($pattern, "2001:0db8:85a3:0000:0000:8a2e:0370:7334"); // 1 Related Patterns
Email Address /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ URL /^https?:\/\/(www\.)?[a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([a-zA-Z0-9()@:%_+.~#?&/=-]*)$/ Phone Number (International) /^\+?[1-9]\d{1,14}$/ Phone Number (US) /^\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/ Phone Number (EU) /^\+?[1-9][0-9]{0,3}[\s.-]?\(?[0-9]{1,5}\)?[\s.-]?[0-9]{1,5}[\s.-]?[0-9]{1,5}$/ IPv4 Address /^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/