in reply to regexp for extracting IP address
Your problem appears to be the range that you are using - instead of using a character range you're trying to match against an invalid '2-5' + 5'.
Instead use '[0-9]+' to match against one or more numerical digits.
The following code matches against your input:
my $input = "netaddr 10.1.4.43 Internet Address True"; my $ipaddress = "unknown"; if ( $input =~ /([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ ) { $ipaddress = $1; } print $ipaddress . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regexp for extracting IP address
by cLive ;-) (Prior) on Oct 11, 2004 at 21:53 UTC |