Re: http_build_query ... argh

From: Date: Fri, 10 Nov 2006 13:08:22 +0000
Subject: Re: http_build_query ... argh
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-244469@lists.php.net to get a copy of this message
Arpad Ray wrote: > Jochem Maas wrote: >> Arpad Ray wrote: >>> return preg_replace('#%5[bd](?=[^&]*=)#ei', >>> 'urldecode("\0")', $s); >>> >> could you explain your regexp - I'd like to replace my version with >> your (if for no other reason than that shorter code is easier to read >> than >> longer code!) BUT until I really understand your regexp I'd feel 100% >> comfortable >> making the replacement. >> > Basically, if we find a '=' before a '&' then we know we're in the > key. > The (?=) is a positive assertion, which says that the bracket must be ah yes - the look ahead assertion was throwing me. > followed by a '=', optionally with any characters except '&' in > between. > Here's the pattern with comments: > > ~ > %5[bd] # the bracket > (?= # must be followed by > [^&]* # any characters except "&" > = # then a "=" > ) > ~eix > thanks very much for the explanation! > Regards, > > Arpad >

« previous php.general (#244469) next »