in reply to Regular Expression Currency Check

Quick update... Try this, basically instead of matching for the correct format match for incorrect:
if($payment !~ m/[0-9]\.[0-9]{3}|[a-z]|\,[0-9]{2}\,|\,[0-9]{2}\./) { print "*match*$payment*match\n";
there...

Replies are listed 'Best First'.
Re^2: Regular Expression Currency Check
by cool_jr256 (Acolyte) on Jun 02, 2005 at 14:10 UTC
    As a side note, the reason you could not force the 2 decimal places is because \.[0-9]{2} still holds true if the decimal places is ".123" or ".1234" etc...
      This code still matchs on 1,00000.00
      Where is the problem here?
      if ( ($payment=~/^\s*\$?(?:\d{1,3},?(?=\d{3}))*[0-9]{1,3}(?:\.\d{2} +)?$/) && ($payment <= 99999.99) ) {print "right";}else{print "wrong";}
        if you do $payment <= 99999.99 it will never match with 1,00000.00 since ',' is a character
      So, your code above fixed the problem?
        basically by matching all the wrong cases, you're left with the correct ones. give it a shot...