jxbma
asked on
What is a valid regex expression for currency?
Hi:
I'm trying to quickly figure out a regex for the following numeric value.
Essentially so it look like a valid currency
- without commas (,)
- or dollar signs ($)
- greater than 0.00
We have uncovered something like this, but it doesn't seem to work:
Thanks,
JohnB
I'm trying to quickly figure out a regex for the following numeric value.
Essentially so it look like a valid currency
- without commas (,)
- or dollar signs ($)
- greater than 0.00
We have uncovered something like this, but it doesn't seem to work:
([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)
Thanks,
JohnB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This will allow no decimal digits and exact two (I don't think 190.1 makes sense):
'^[1-9]\d*(\.\d\d)?|^0.([1 -9][0-9]|0 [1-9])'
'^[1-9]\d*(\.\d\d)?|^0.([1
ASKER
Terrific!
I just extended it to be: ^[1-9]\d*\.\d\d|^0.([1-9][ 0-9]|0[1-9 ])|^[1-9]\ d*
Thanks,
JB
I just extended it to be: ^[1-9]\d*\.\d\d|^0.([1-9][
Thanks,
JB
ASKER
Thanks,
JB