Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Match a Range of IP's

by conrad (Beadle)
on Sep 30, 2004 at 16:15 UTC ( #395391=note: print w/replies, xml ) Need Help??


in reply to Match a Range of IP's

[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...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://395391]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2021-01-19 15:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?