in reply to Validate Ip address Regexp

Regexp::Common already has a regex for you. Don't stress building your own.

use Regexp::Common qw/ net number /; # these become available: # $RE{net}{IPv6} # $RE{net}{IPv4} if ( $ip =~ m/$RE{net}{IPv4}/ ){ print 'match!' }

Neil Watson
watson-wilson.ca

Replies are listed 'Best First'.
Re^2: Validate Ip address Regexp
by AnomalousMonk (Archbishop) on Nov 28, 2015 at 14:00 UTC
    Don't stress building your own.

    ... except as an exercise for building your familiarity with and confidence in regex construction.


    Give a man a fish:  <%-{-{-{-<