in reply to Re: Re: Search question
in thread Search question
The regular expression is assuming that all of the prices in the description will begin with a $, and that they are properly formatted in terms of money (no misplaced commas and such). I believe this will do what you are looking for.my ($LowValue, $HighValue) = split("-", $form{'searchprice'}); #makes + the two values to compare $Price with if ($desc =~ m/\$(\d{1,3},?[\d{3},?]*\.?\d{0,2})/) { my ($Price) = $1; #sets $Price equal to the match in the regex $Price =~ s/,//g; #Strips out all commas if (($LowValue <= $Price) && ($Price <= $HighValue)) { print "$desc\n"; } } else { print "No price found in $desc\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Search question : Price Regex
by SysAdm (Novice) on Mar 12, 2001 at 01:16 UTC | |
by dfog (Scribe) on Mar 12, 2001 at 19:58 UTC |