+ Start a Discussion

REGEX to validate IPv6



I am looking for a working REGEX to validate IPv6. Any help on this is much appreciated.


I'd like to refer you to http://cpansearch.perl.org/src/TMONROE/Net-IPv6Addr-0.2/IPv6Addr.pm. You'll see how they implemented ipv6_parse. It's not pretty. RFC1884 regarding valid forms of addresses represents a royal pain of a regex. I believe the minimum "single regex" pattern you'd need would probably be several hundred characters long, and very deeply nested.