in reply to Regex Help
I would prefer to seem/\((.*?)\)/g;
I suppose in pure terms both work acceptably, but the class one seems more understandable as 'up to a )' to me.m/\(([^)]*)\)/gm;
And secondly, using the match in list contents gives you all of the matches you need.use strict; use warnings; my $s=<<EOF; [whois.arin.net] Fuse Internet Access (NETBLK-FUSE-NET-BLK-1) FUSE-NET-BLK-1 216.68.0.0 - 216.68.255.255 Fuse Modem Ports (NETBLK-FUSE-216-68-32-0) FUSE-216-68-32-0 216.68.32.0 - 216.68.47.255 EOF if (my @parts = ($s=~/\(([^)]*)\)/gm)) { print "\n@parts\n"; }
Update:
Fixed my incorrect observation about the m modifier for the regex as correctly pointed out by dvergin in comment on Re: Regex Help. My apologies
HTH
Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regex Help - Correct use of /m
by dvergin (Monsignor) on Sep 07, 2001 at 02:51 UTC | |
by demerphq (Chancellor) on Sep 07, 2001 at 03:26 UTC |