When I use this code my regex works fine...
<?php
$ips = array("1.0.0.0", "0.0.0.0", "255.255.2", "999.999.999.999", "0.1.1.1", "1.1.1.", "123.123.123.123", "255.255.255.255", "001.000.000.000");
$regex = "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|0?[1-9][0-9]|0?0?[1-9])(.){3}$";
foreach($ips as $ip) {
print("Testing <b>" . $ip . "</b>: ");
if(preg_match("/" . $regex . "/i", $ip))
print("valid");
else
print("not valid");
print("<br />\n");
}
?>
And by the way... it should alow the middle two octets to be zero... or am I missing someting here?