Reputation: 497
I'm very bad at regex.
The below expression does mostly what I need, but it requires the user to input "0.XX" for decimals, rather than allowing ".XX", without having to type the "0".
Could someone give me the heads up on this?
Thanks!
ValidationExpression="^([0-9]{1,3}(\.[0-9]{1,2})?)?$"
Upvotes: 1
Views: 50
Reputation: 414
The {1,3}
means that the RE will allow 1 to 3 of the previous atom (digits 0-9
), so just change it to {0,3}
to allow 0 to 3 digits preceding the decimal.
Upvotes: 5