Regex tester / pattern library

Regex: ipv6 address (full form)

/^([0-9a-f]{1,4}:){7}[0-9a-f]{1,4}$/i Test it live

How it works

Eight colon-separated groups of 1–4 hex digits — the full, uncompressed IPv6 form.

Honest caveats

Deliberately does not handle :: zero-compression — the complete IPv6 grammar regex runs several hundred characters and is unmaintainable. Normalize (expand ::) first, or parse with a proper library; use this to match already-expanded addresses.

Matches

  • 2001:0db8:0000:0000:0000:8a2e:0370:7334
  • fe80:0:0:0:0:0:0:1

Doesn't match

  • ::1
  • 2001:db8::8a2e:370:7334
  • 2001:0db8:0000:0000:0000:8a2e:0370

More patterns