regexhelper
Test a pattern. Copy a ready-made one. No signup.

Regex to Match an IPv6 Address

Copy the pattern, paste your text below, and watch it highlight every full-form IPv6 address. Below the tester: what each group means and why :: compression needs more.

/ /

What this pattern matches

This matches a full, uncompressed IPv6 address: eight groups of one to four hexadecimal digits separated by colons.

How it works, part by part

[A-Fa-f0-9]{1,4} — one hextet: one to four hex digits.

(?:…:){7} — that hextet followed by a colon, repeated seven times.

[A-Fa-f0-9]{1,4} — the final eighth hextet.

About :: compression

IPv6 lets you collapse runs of zero groups to :: (e.g. 2001:db8::1). Matching every compressed form needs a much longer alternation; use this pattern when your data is normalised to full form.

FAQ

Does it match compressed addresses like 2001:db8::1?

No. This simple pattern matches only the full eight-group form. Compressed :: forms need a longer alternation.

Is it case sensitive?

No. It accepts both upper and lower hex digits (A–F and a–f).