regex question

Garrett Goebel garrett at scriptpro.com
Mon Jul 7 18:37:48 CDT 2003


Jason Crowe wrote:
>
> I have this regex:
>
> $content =~ m/Current bid:n</font>n</td>n.+n<.+$([0-9.,]+)</
>
> That should match for this string and place the number into $content:
>
> Current bid:
> </font>
> </td>
> <td width="100%">
> <font face="Arial" size="2"><b>US $9.99<

my $url = "http://cgi.ebay.com/aw-cgi/eBayISAPI.dll?ViewItem&item=$ARGV[0]";

if($ARGV[0]) {
my $content = get($url);
my ($price) = $content =~ /Current bid:.*?$([0-9.,]+)/s;
$price =~ s/,//g  if $price;
}

I missed your earlier post... Does this work for you? It sets a variable
$price to the value of whatever you've scraped after the first $ after
"Current bid:".

The trailing 's' in the regex says to treat the hole thing as a single line.
At which point you can pretty much ignore the end-of-line issue.

--
Garrett Goebel
IS Development Specialist

ScriptPro                  Direct: 913.403.5261
5828 Reeds Road            Main:   913.384.1008
Mission, KS 66202          Fax:    913.384.2180
www.scriptpro.com          garrett at scriptpro dot com





More information about the Kclug mailing list