Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
I have a doubt regarding a Perl regex, pls check the code below,
my $loc_data = "Location: England Location: Scotland Location: Finland "; my $location = $1 if ($loc_data =~ /Location:(.*)/i); print $location ; exit;
Here, I am getting the output as England, because its the first one. Okay, now what modifications we should do if we want to take the second one(Here, its Scotland) or the third one(Here, its Finland). Is there a way to do this?
Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex Help!
by kcott (Archbishop) on Sep 19, 2013 at 07:54 UTC | |
by Anonymous Monk on Sep 19, 2013 at 08:11 UTC | |
by Anonymous Monk on Sep 19, 2013 at 08:12 UTC | |
by Anonymous Monk on Sep 19, 2013 at 09:13 UTC | |
|
Re: Regex Help!
by daxim (Curate) on Sep 19, 2013 at 09:22 UTC | |
|
Re: Regex Help! (perlrequick Extracting matches)
by Anonymous Monk on Sep 19, 2013 at 07:36 UTC | |
by Anonymous Monk on Sep 19, 2013 at 08:15 UTC | |
by Anonymous Monk on Sep 19, 2013 at 08:22 UTC | |
|
Re: Regex Help!
by Laurent_R (Canon) on Sep 19, 2013 at 09:30 UTC |