| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Subscribe and Support WebmasterWorld|
|Regex - extracting: intitle: intext: etc|
| 3:57 pm on Jun 25, 2005 (gmt 0)|
I need some help extracting the text for intitle: intext: search functions.
$q = 'site:webmasterworld.com intitle:google adsense intext:contextual advertising';
Text to be extracted:
$val[intitle] = 'google adsense';
$val[intext] = 'contextual advertising';
I've tried lots of variants similar to:
$match[intitle] = '/(^¦ )intitle:?(.+)( intitle:¦ intext:)/i';
preg_match($match[intitle], $q, $varInTitle);
But I'm crap at regex... :( nothing is working the way I want.
Can anyone help?
| 5:27 pm on Jun 25, 2005 (gmt 0)|
$pattern = '/intitle:(.*)intext:(.*)/';
preg_match($pattern, $q, $matches);
list($wholematch, $intitle, $intext) = $matches;
Now you have two variables, $intitle and $intext containing the values.
| 7:38 pm on Jun 25, 2005 (gmt 0)|
Awesome mate, thats definetly pointed me in the right direction!
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
© Webmaster World 1996-2014 all rights reserved