On Die, 2010-02-02 at 17:49 -0800, - wrote:
> Try this regex for detecting an IPv4-compatible IPv6 address:
> 
>  ... =~  qr/^::FFFF:(\d{1,3}(\.\d{1,3}){3})$/i   ...
To get even more anal:
No one forbids to avoid the leading "::" or write the optional "0"
before and(or after it. So that could be
----  snip  ----
... =~ qr/^((0+:)*::(0+:)*|(0+:){6})FFFF:(\d{1,3}(\.\d{1,3}){3})$/i ...
----  snip  ----
Caveat emptor 1: Not tested etc.
Caveat emptor 2: Since (normal) regexps can't calculate, we cannot avoid
getting false positives with too many 0 with "(0+:)*::(0+:)*" for an
IPv6 address.

Perhaps reason enough to simply use Net::IP.
And if Net::IP gets it wrong, we can blame them (and send a patch).

        Bernd
-- 
Bernd Petrovitsch                  Email : [email protected]
                     LUGA : http://www.luga.at

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list [email protected]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Reply via email to