Igor Igor - 1 month ago 8
Perl Question

Creating a regex to find an ip address (not including 192.168)

i'm using perl and i want to create a regex to find an IP address, (but not 192.168 and not a domain)

I trying to use this:

$record='192.168.23.106';
if($record =~ /^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})(?:(?<!192\.168)[\S\s])*$/ )
{print "$record $1";}


But it doesn't work as i expected.

Answer
/^(?!192\.168)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[\S\s]*$/