regex question

Charles Steinkuehler charles at steinkuehler.net
Tue Jul 8 18:20:15 CDT 2003


Jason Crowe wrote:
> Thanks for the response. I ended up figuring most of the program out 
> based on the one good regex statement that I had. The only problem I 
> have left is that this:
> _____________________________
> if($content =~ 
> m/Price:s*ns*</font>s*ns*</td>s*n*.+n*s*<.+$([0-9.,]+)</) {
>         $currently = $1;
>          $currently =~ s/,//g;
>     }
> ____________________________
> won't match this:
> ____________________________
> 
> <td nowrap="yes" valign="top">
> <font face="Arial" size="2"><img src="http://pics.ebay.com/aw/pics/bin_15x54.gif" alt="Buy It 
Now"> Price:</font>
> </td>

I'm not a perl guru (that is perl, isn't it?), but I think your problem 
is with the Price:s*ns*</font> section of the above regex.  If I'm 
reading it correctly, you're *REQUIRING* a newline between optional 
whitespace (s*ns*), and unlike the html snippit below (that works), 
there isn't a newline in the html above.  Change to s*n*s* (or will 
[sn]* work in perl?) and it will probably work...

> <td valign="top">
> <font face="Arial" size="2"><b>US $361.51</b></font>
> ____________________________
> 
> even though this:
> ____________________________
> if($content =~ m/Winnings*bid:s*ns*</font>s*ns*</td>s*n*.+n*s*<.+$([0-9.,]+)</) {
> 		$currently = $1;
>      	$currently =~ s/,//g;
>     	}
> ____________________________
> 
> does match:
> ____________________________
> 
> <font face="Arial" size="2">
> 						Winning bid:
> 						</font>
> </td>
> <td width="100%">
> <font face="Arial" size="2"><b>US $10.50<font face="Verdana" size="1" 
color="#666666"></font></b></font>
> </td>
> ____________________________
> I don't see any differance that would cause this to mess up. :( I am reading all I can on regex's 
and it's a little more involved than I had hoped.

Doesn't everything wind up being more complicated than it seems like it 
should be? :)

-- 
Charles Steinkuehler
charles at steinkuehler.net




More information about the Kclug mailing list