AF_One has asked for the wisdom of the Perl Monks concerning the following question:
Wise Monks,
I'm having some trouble with a RegEx that matches within a <coordinates> (KML) tag...
$kmlfile = "<coordinates>1.0001,2.0002,0 3.0003,4.0004,0 ...</coordina +tes>"; if ($kmlfile =~ m{<coordinates>(.*)</coordinates>}g) { $coordinates = $1; while ($coordinates =~ m/\G(\d*\.\d*,\d*\.\d*),0*/s*/gs) { push @coords, $1; } }
The only problem with this is that @coords only gets the first pair (1.0001,2.0002).
How do I populate each element with pairs as shown below? I thought that the \G operator would hold the previous search's last position and start from there on the next iteration to fill the array.
$coords[0] = 1.0001,2.0002; $coords[1] = 3.0003,4.0004; ...
Your insight is most appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: \G inline RegEx operator
by almut (Canon) on Jun 03, 2008 at 22:42 UTC | |
by Anonymous Monk on Jun 03, 2008 at 22:55 UTC | |
by almut (Canon) on Jun 03, 2008 at 23:03 UTC | |
by AF_One (Novice) on Jun 03, 2008 at 23:30 UTC | |
|
Re: \G inline RegEx operator
by johngg (Canon) on Jun 03, 2008 at 23:17 UTC | |
|
Re: \G inline RegEx operator
by pc88mxer (Vicar) on Jun 03, 2008 at 23:23 UTC | |
|
Re: \G inline RegEx operator
by AF_One (Novice) on Jun 03, 2008 at 23:34 UTC |