in reply to Regular Expression Currency Check

It works fine for me. I changed the char classes to \d, but that doesn't change anything. I backslashed the '.' so it matches a literal '.' and not any character. Perhaps your string has whitespace around it that you're not expecting?
/^\s*\$?(\d{1,3},(\d{3},)*\d{3}|\d+)(\.\d\d)?\s*$/
Try that...

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: Regular Expression Currency Check
by Anonymous Monk on Jun 02, 2005 at 13:33 UTC
    Hi I changed your code to:
    /^\s*\$?(\d{1,3},(\d{3},)*\d{3}|\d+)(\.\d{2})?\s*$

    To enforce the two decimal digits, but it's not picking up on it, it should like that right?
      I think I got it, I just would like to add the last check, if value is more them 99999.99 to the reg. exp. as well, and here is the code so far:

      if ( ($payment=~/^\s*\$?(\d{1,3},(\d{3},)*\d{3}|\d+)(\.\d +{2})\s*$/) || ($payment > 99999.99) ) { print "^*$1-$2-$3-match*$payment*match*^<br>"; }else{print "No match";}