Re: Regular Expresion Work on IP address
| From: | DL Neil | Date: | Wed, 04 Dec 2002 19:47:40 +0000 |
| Subject: | Re: Regular Expresion Work on IP address | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127026@lists.php.net to get a copy of this message | ||
John,
> I think it'd be hard to verify the range with a regex. ip2long and long2ip
> do not validate. So, an option would be to write your own little function
> that splits the $ip on the period, verifies there are 4 parts, then checks
> that each part is between 1 and 255 inclusive.
My other post on the subject notwithstanding, I agree.
When I get time/when I get a round tuit, I'd like to do a performance test
on the (short) IP RegEx against what you have outlined:
explode against "."
run resultant array through 0-255 validation function
- and still have the semantic issues of 0.0.0.0, etc...
Meantime, will sit here whistling and quietly muttering into my beard (and
dreaming of tuits),
=dn