note 30025 modified in function.preg-match by tix
| From: | tix@php.net | Date: | Wed, 05 Mar 2003 10:26:35 +0000 |
| Subject: | note 30025 modified in function.preg-match by tix | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-44859@lists.php.net to get a copy of this message | ||
just a little regexp that match correct ip address or network if
they are structured as:
xxx.yyy.yyy.yyy,
(where xxx is a number between 1 and 254 and yyy a number
between 0 and 254)
preg_match("/^(((([1-9])|([1-9][\d])|((1[\d]{2})|(2[0-4]
[\d])|(25[0-4])))(\.(([\d])|([1-9][\d])|((1[\d]{2})|(2[0-4]
[\d])|(25[0-4])))){3})|(0(\.0){3}))$/",$ip);
there is maybe (surely) a nicer way but this one works
--was--
just a little regexp that match correct ip address or network if
they are structured as:
xxx.yyy.yyy.yyy,
(where xxx is a number between 1 and 254 and yyy a number
between 0 and 254)
preg_match("/^(((([1-9])|([1,2][\d])|((1[\d]{2})|(2[0-4][\d])
|(25[0-4])))(\.(([\d])|([1,2][\d])|((1[\d]{2})|(2[0-4][\d])
|(25[0-4])))){3})|(0(\.0){3}))$/",$ip);
there is maybe (surely) a nicer way but this one works
http://www.php.net/manual/en/function.preg-match.php