in reply to Reg Ex to find IP address in range

/\A 111 [.] 255 [.] ( \d | [1234]\d | 5[012345] ) [.] ( \d | [1234]\d | 5[012345] ) \z/x;

...should work ( with /x modifier used to enhance readability ), but if you're not limited to a regexp, a cleaner ( and more easily reusable!) solution would be something like...

return 1 if /\A 111 [.] 255 [.] (\d+) [.] (\d+) \z/x && $1 <= 55 && $2 <= 55;

    --k.


Update: Fixed typo; thanks CS!

Replies are listed 'Best First'.
Re: Re: Reg Ex to find IP address in range
by CombatSquirrel (Hermit) on Aug 28, 2003 at 17:15 UTC
    Errrm... Concerning your RegEx: What about '111.255.11.11'? Should be a valid IP, but is not recognized by your pattern. Probably just a typo, change [234] to [1234]. ;-)
    Cheers, CombatSquirrel.
    Entropy is the tendency of everything going to hell.