T
ToolPrime

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