clone4 has asked for the wisdom of the Perl Monks concerning the following question:
I need to store "var1=" and "var2=" into the array, however extending it to any other possible variables (if there was var3, var4 etc.)sub check { my $url = "http://google.com/?var1=aaaa&var2=aa"; my $count = 0; my @arr; return undef if $url !~ /^http:\/\/.*?\?.*?=.*?$/i; $count++ while $url =~ /&/g; $url =~ s/^(.*?=)(.*?)$/$1/ and return $url if $count<1; $arr[0..$count] = $url =~ /^http:\/\/.*?\?(?:([\w\d]*=)(?:.*[&]?))*/gi +; say $_ foreach @arr; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: url get variables regex
by Your Mother (Archbishop) on May 13, 2009 at 23:37 UTC | |
by clone4 (Sexton) on May 13, 2009 at 23:52 UTC | |
|
Re: url get variables regex
by Marshall (Canon) on May 13, 2009 at 23:34 UTC | |
by clone4 (Sexton) on May 13, 2009 at 23:54 UTC | |
|
Re: url get variables regex
by JavaFan (Canon) on May 13, 2009 at 23:24 UTC | |
by clone4 (Sexton) on May 13, 2009 at 23:39 UTC | |
by Anonymous Monk on May 14, 2009 at 04:49 UTC |