in reply to regular expression assistance
You want to match a "hosts" line where you have an IP (\S*) followed by whitespace (\s+) followed by the hostname. Perhaps a better regex would be:next unless $hfileline =~/^\S*\s+$hNames/;
To force matches against real lines, and not match against commented-out entries. Another way to match an IP address without using "<= 255" is:next unless $hfileline =~/^[\d.]+\s+$hNames/;
if( $vmServerIP =~ m/^(?:(?:\d|[1-9]\d|1\d\d|2(?:[0-4]\d|5[0-5]))\.){3 +}(?:\d|[1-9]\d|1\d\d|2(?:[0-4]\d|5[0-5]))/ ){
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regular expression assistance
by notasaint (Novice) on May 09, 2008 at 22:14 UTC |