XP is just a number | |
PerlMonks |
Re: IPAddress check (updated)by haukex (Archbishop) |
on Mar 13, 2018 at 11:46 UTC ( [id://1210806]=note: print w/replies, xml ) | Need Help?? |
"is not working" is not really an adequate problem description. Please see I know what I mean. Why don't you? But take a look at your regular expression: \d{1,3} vs. \d{1-3} - why the difference? One is right, the other is wrong. See perlrequick and perlretut. Note that even if you fix that, the regular expression will still match invalid IP's like 999.999.999.999. Instead of reinventing the wheel, I'd recommend Regexp::Common::net:
Update: Added the word boundary \b to the above regex, because otherwise it would have matched something like 1111.1.1.1 (because 111.1.1.1 is a valid IP) or 256.255.255.256 (because 56.255.255.25 matches).
In Section
Seekers of Perl Wisdom
|
|