YZlat
asked on
Need a regex for dollar amount validation
I have tried two regex expressions so far:
and
I need to validate dollar amounts with or without dollar sign, with or without decimal points and with or without commas.
The first one does not account for any commas, and the second one allows commas in the wrong places. Can anyone help me with a regex that would cover everything?
^\$?[0-9]+(\.[0-9][0-9])?$
and
^\$?\d+(?:,\d+)*(?:.\d{2})?$
I need to validate dollar amounts with or without dollar sign, with or without decimal points and with or without commas.
The first one does not account for any commas, and the second one allows commas in the wrong places. Can anyone help me with a regex that would cover everything?
^\$?\d{1,3}(,\d{3})*(\.\d\ d)?$
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect! Thank you
You're welcome.
Thanx 4 axxepting
Thanx 4 axxepting