Gossamer Forum
Home : General : Perl Programming :

need regex help

Quote Reply
need regex help
I'm making a google version of altavista.cgi for educational purposes and won't be distributing it w/o permission.
I've parsed the html and i'm parsing the results like this

while ($results =~ m#<p><a href=(.+?)>(.+?)</a><br><font size=-1>(.+?)<br><span class=f><font size=-1>Description:</font></span> (.+?)<br>#sog) {

some of the links return ok, but then some come back distorted and i noticed some links don't have a description. So i was wondering if i could make this part:

<br><span class=f><font size=-1>Description:</font></span> (.+?)

optional?
Lavon Russell
LookHard Mods
lavon@lh.links247.net
Post deleted by RedRum In reply to

Last edited by:

RedRum: Oct 8, 2001, 9:58 AM
Quote Reply
Re: [Bmxer] need regex help In reply to
one thing i tried to do was
while ($results =~ m#(<p><a href=(.+?)>(.+?)</a><br><font size=-1>(.+?)<br><span class=f><font size=-1>Description:</font></span> (.+?)<br>|<p><a href=(.+?)>(.+?)</a><br><font size=-1>(.+?)<br>)#sog) {
but regex doesn't accept it. saying i have an unmatched ().

Lavon Russell
LookHard Mods
lavon@lh.links247.net
Quote Reply
Re: [Bmxer] need regex help In reply to
Try:

while ($results =~ m#(<p><a href=(.+?)>(.+?)</a><br><font size=-1>(.+?)(<br><span class=f><font size=-1>Description:</font></span>)(.+?))?<br>#sog) {

Last edited by:

RedRum: Oct 8, 2001, 10:38 AM
Quote Reply
Re: [RedRum] need regex help In reply to
Thanks for the code Paul. I found that it does work, but i stopped working because the results worked for the first few pages, and then there'd be a new problem, so since i was just doing it for fun, i'm gonna stop.
Lavon Russell
LookHard Mods
lavon@lh.links247.net