Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Regular Expression to Match IP Addressby Dietz (Curate) |
on Oct 03, 2004 at 13:06 UTC ( [id://396001]=note: print w/replies, xml ) | Need Help?? |
This should work for your needs:
Update: Changed (?: [0-9][0-9]? ) to (?: [1-9][0-9]?|[0-9] ) so that it won't accidently match an octet with only 2 or more zeros or an octet with leading zero (i.e. 00.0.0.0 or 192.186.0.01) Now this will only match addresses from 0.0.0.0 to 255.255.255.255 (assuming the address in $ip is already chomped)
In Section
Seekers of Perl Wisdom
|
|