in reply to Re: Regular Expression Currency Check
in thread Regular Expression Currency Check

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...

Replies are listed 'Best First'.
Re^3: Regular Expression Currency Check
by Anonymous Monk on Jun 02, 2005 at 14:50 UTC
    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
Re^3: Regular Expression Currency Check
by Anonymous Monk on Jun 02, 2005 at 14:12 UTC
    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...