dotted-quad RE

Joshua Goodall joshua at roughtrade.net
Thu Jul 11 02:09:59 CDT 2002


I'm using the following (independently contrived) RE to pick out dotted-quad
IPv4 addresses (like 192.168.0.1):

$dqa = qr/1?\d{1,2}|2[0-4]\d|25[0-5]/;
$dq  = qr/(?:$dqa\.){3}$dqa/;

print "matched" if $input =~ /^$dq$/;

Anyone know of a simpler (or faster) pattern?

cheers
Joshua



More information about the Melbourne-pm mailing list