in reply to A regex I cant get my head around
Seems to me that the variable $key in your code should be renamed $value, because that is what it is really trying to capture. Also, depending upon what the goal really is for this code, i might suggest using a CPAN module such as URI to pull out the key/value pairs:use strict; for (qw(foo foo& &foo foo&bar)) { /([^&]+)\&/; print "$_ - $1\n"; }
Notice that KEY is last, and it's value is not succeeded by an ampersand.use strict; use URI; my $uri = URI->new(); $uri->query('THING=super%20hero&KEY=foobar'); my %hash = $uri->query_form(); print $hash{KEY}, "\n";
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: A regex I cant get my head around
by Anonymous Monk on Aug 03, 2002 at 21:08 UTC | |
by jeffa (Bishop) on Aug 03, 2002 at 21:13 UTC |