homepage Welcome to WebmasterWorld Guest from 54.205.106.111
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Regex - extracting: intitle: intext: etc
XMLMania




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

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?

Cheers

 

coopster




msg:1292070
 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.

XMLMania




msg:1292071
 7:38 pm on Jun 25, 2005 (gmt 0)

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

KUDOS

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved