Page 1 of 1

sub string for q

Posted: Mon Aug 30, 2010 6:35 am
by roice
hello,
I getting url string, for example:
[text]http://www.google.com/#hl=en&source=hp& ... 8db929eee0[/text]

How can I get into variable the string between "&q" and "&" (in this example it's: "php"

?

Thank you in advance,
Roi

Re: sub string for q

Posted: Mon Aug 30, 2010 6:44 am
by amargharat
You can use regex. as follows,

Code: Select all

$url =   'http://www.google.com/#hl=en&source=hp&q=php&aq=f&aqi=g10&aql=&oq=&gs_rfai=&pbx=1&fp=93c3c78db929eee0';
preg_match("/\&q=(.*?)\&/", $url, $matches);

$str = $matches[1];

Re: sub string for q

Posted: Mon Aug 30, 2010 6:57 am
by roice
Thank you amargharat!

Re: sub string for q

Posted: Mon Aug 30, 2010 7:27 am
by roice
amargharat - can you please write it to me in ASP ?

Re: sub string for q

Posted: Mon Sep 06, 2010 2:33 am
by roice
Maybe someone else?