#!/usr/bin/perl -w my %form = ( 'searchprice' => "15001-9999999", ); my @Tests = ('$1600', ' $1,300 ', ' $1,600,000.43 ', ' $1600. ', ' $1600.43 '); foreach my $desc (@Tests) { print "Testing $desc\n"; my ($LowValue, $HighValue) = split("-", $form{'searchprice'}); #splits two values to compare desc to if ($desc =~ m/ \$ #Matches the dollar sign ( #Begins gathering the digit grouping \d{1,3},? #Grabs between 1 and 3 digits. #There must be at least one and at most #3 before the first comma. [\d{3},?]* #This grabs groups of 3 digits, #and the comma after them if it exists \.?\d{0,2} #This grabs the final decimal point and #up to two places after it if they exist )#Ends the digit grouping /x #tells it to ignore whitespace ) { my ($Price) = $1; #sets $Price equal to the match in the regex $Price =~ s/,//g; #Strips out commas print "TestPrice $Price\n"; if (($LowValue <= $Price) && ($Price <= $HighValue)) { print "$desc\n"; } } else { print "No price found in $desc\n"; } print "\n"; }