I need a regex that will match on a price or amount.
It should match on these
- 100
- 410.00
- 0.12
but not these
- 100.000
- -600.00
- .12
- .1234
This works for all of the above cases except for single values like 1
/^[0-9]*\.?[0-9]{2}+$/
How can I adjust it so single integers will match? And can anyone explain why the current one is wrong?
I suggest a small correction to Tom Revell’s regular expression since you could still input several 0’s as first digits. ie 00002.23 which is most likely incorrect.