Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Regex - extracting: intitle: intext: etc



3:57 pm on Jun 25, 2005 (gmt 0)

10+ Year Member

I need some help extracting the text for intitle: intext: search functions.

for example:

$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)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

$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)

10+ Year Member

Awesome mate, thats definetly pointed me in the right direction!



Featured Threads

Hot Threads This Week

Hot Threads This Month