-6

I wan to make regex for money that can validate amount with Commas, assumed decimals, negative sign or parentheses, dollar sign, decimals, numeric only.

I have used the following expression

((\\$?(([0-9]{0,1})?\\.[0-9]{1,2}))|(\\$?([1-9]{1}[0-9]{0,2}([,][0-9]{3})*)(\\.[0-9]{1,2})?))

It works fine for $23,000 etc. but how to handle negative sign or parentheses

Please advice.

  • 7
    Try, post, and we'll give you an offer you can't refuse. – Maroun Mar 11 '13 at 08:53
  • 2
    It's amazing that i lost so much reputation by asking question :) it's really de-fostering the user's trust on such system... –  Mar 11 '13 at 09:22
  • @deadlock I did it, its not working.. –  Mar 11 '13 at 09:28
  • @Imran - you might want to read through the FAQ on [How To Ask](http://stackoverflow.com/questions/how-to-ask). If you read through and post more detailed questions in the future they won't get down-voted. – Perception Mar 11 '13 at 09:53

1 Answers1

4

Currency amount US & EU (cents optional) Can use US-style 123,456.78 notation and European-style 123.456,78 notation. Optional thousands separators; optional two-digit fraction

Match; JGsoft:
^[+-]?[0-9]{1,3}(?:[0-9]*(?:[.,][0-9]{2})?|(?:,[0-9]{3})*(?:\.[0-9]{2})?|(?:\.[0-9]{3})*(?:,[0-9]{2})?)$

Reference: here

Community
  • 1
  • 1
dlock
  • 9,447
  • 9
  • 47
  • 67