10
rated 0 times
[
16]
[
6]
/ answers: 1 / hits: 18011
/ 13 Years ago, fri, october 7, 2011, 12:00:00
I'm trying to get a regex for an amount:
ANY DIGIT + PERIOD (at least zero, no more than one) + ANY DIGIT (at least zero no more than two [if possible, either zero OR two])
What I have is:
/^d+.{0,1}+d{0,2)+$/
...obviously not working. Examples of what I'm trying to do:
123 valid
123.00 valid
12.34.5 invalid
123.000 invalid
Trying to match an amount with or without the period. If the period is included, can only be once and no more than two digits after.
More From » regex