On Thursday 22 November 2007 23:23, howa wrote:
> Hello,

Hello,

> I want to match a query string,
>
> e.g.
>
> http://abc.com/test.cgi?TEST=1&.type=xmlrpc&type=2
>
> I want to extract the .type, currently i use
>
> $ENV{"QUERY_STRING"} =~ /\.type=(.+?)(&|$)/; # This is okay
>
> but back reference seem no good,

Why does it "seem no good"?  Perhaps you should use non-capturing 
parentheses instead.

Or maybe this would work better:

$ENV{ QUERY_STRING } =~ /\.type=([^&]+)/;


> i rewrite as
>
> $ENV{"QUERY_STRING"} =~ /\.type=(.+?)[$&]/;  # seem better, but not
> working

[$&] is a character class that matches either the '$' character or the 
'&' character.  In the previous example '$' in a pattern but not in a 
character class is a meta-character that matches at end-of-line, not 
the literal '$' character.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to