Forum Moderators: coopster

Message Too Old, No Replies

Regex Help - preg match all

regular expressions help

         

rushcreek

3:28 pm on Nov 16, 2006 (gmt 0)

10+ Year Member



I want to use preg_match_all to scrape every occurrence of the url
on a google serp from this area:

<span class="a">www.website<b>something</b>.com/ - 44k - </span><nobr>

I've got this to work with ask and aol serps but not google, yahoo, or MSN. I'm a regex idiot and I don't understand it's finer points I tried using:

$pattern = '<br><span class=.+a.+>(.*)<\/span><nobr>';//the ".+" seems to work
preg_match_all('/'.$pattern.'/i', $page, $seurl);//I return $seurl

I'm hoping to figure out the other two with the help I get from this one.

Thanks in advance.

[1][edited by: dreamcatcher at 6:33 pm (utc) on Nov. 16, 2006]
[edit reason] Generalized url. [/edit]

rushcreek

6:29 pm on Nov 16, 2006 (gmt 0)

10+ Year Member



Figured it out. Thanks.

$pattern="\<span class=a\>(.*?)\<\/span\>";

coopster

4:31 pm on Nov 20, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, rushcreek.

Glad you got it sorted. There are some good discussions in our PHP Forum Library [webmasterworld.com] that might interest you regarding regular expressions.

Learning PHP - Books, Tutorials and Online Resources [webmasterworld.com]
Regular expressions [webmasterworld.com]