in reply to Re: Regexp to match IP address
in thread Regexp to match IP address

I like this one using quoted reg ex

my $ip = '192.168.255.254'; # for example # Set up the reg ex my $ipno = qr/ 2(?:5[0-5] | [0-4]\d) | 1\d\d | [1-9]?\d /x; # To test if ( $ip =~ /^($ipno(?:\.|$)){4}/ ){ print "IP OK\n"; };

I went for an interview at Arm in Cambridge, UK. They asked me to write one on the board and I wrote some lame one .. and later ... brooding on my poor attempt set out to make a better one. Driven by failure? Or maybe just really irritated by it. I still got the job :)