No such thing as a small change | |
PerlMonks |
Re: Match a Range of IP'sby conrad (Beadle) |
on Sep 30, 2004 at 16:15 UTC ( [id://395391]=note: print w/replies, xml ) | Need Help?? |
[1-99] is a character range, not a number range, so it'll match 1 .. 9 or 9 (i.e. it's the same as [1-9]).
One solution is to use [1-9]\d? instead, which will match 1 .. 9 and any two-digit number (but if you ever get IP addresses of the form "001" this will fail). A better option would be to use (\d+) and add " && $1 >= 1 && $1 <= 99" to the end of the line; bear in mind that that will run into trouble if you have multiple IP addresses per line because of your /g though...
In Section
Seekers of Perl Wisdom
|
|