Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I need a regex which will return "nj" and "nyc" from the above.newjersey-ab1.net agg nj1-dpta1 net 10 newyork-cd1.net agg nyc-dpt1 net NA
doesn't quite do it. Can anyone help out?....snip open (CONFIG, $config_file) || die "Cannot open $config_file:$!\n"; while (my $line = <CONFIG>) { chomp $line; next if ($line =~ /^\#/); my ($router, $cache, $tmp, $as, $sample) = split (' ', $line); if ($tmp =~ /(\w+)(.*)\-(.*)dta/) { my $host = $1; print "$host\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple Regex Question
by Fastolfe (Vicar) on Jan 30, 2001 at 00:36 UTC | |
|
Re: Simple Regex Question
by arturo (Vicar) on Jan 30, 2001 at 00:39 UTC | |
|
Re: Simple Regex Question
by KM (Priest) on Jan 30, 2001 at 00:51 UTC | |
|
Re: Simple Regex Question
by lemming (Priest) on Jan 30, 2001 at 00:39 UTC | |
|
Re: Simple Regex Question
by sierrathedog04 (Hermit) on Jan 30, 2001 at 01:26 UTC | |
by KM (Priest) on Jan 30, 2001 at 01:35 UTC | |
by sierrathedog04 (Hermit) on Jan 30, 2001 at 02:52 UTC | |
by KM (Priest) on Jan 30, 2001 at 03:03 UTC | |
by sierrathedog04 (Hermit) on Jan 30, 2001 at 07:35 UTC |