note 52836 deleted from function.preg-match by colder

From: Date: Mon, 18 Jun 2007 18:22:21 +0000
Subject: note 52836 deleted from function.preg-match by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127599@lists.php.net to get a copy of this message
Note Submitter: Chortos-2 ---- max wrote a fix for satch666's function, but it too has a little bug... If you write IP 09.111.111.1, it will return TRUE. <? $num="(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; /* \\d => numbers 0-9 [1-9]\\d => numbers 10-99 --> Here was the bug in max's code 1\\d\\d => numbers 100-199 2[0-4]\\d => numbers 200-249 25[0-5] => numbers 250-255 */ if (!preg_match("/^$num\\.$num\\.$num\\.$num$/", $$ip_addr)) echo "Wrong IP Address\\n"; ?> P.S. Why did you write [0-9] and not \\d?

« previous php.notes (#127599) next »