I need a regular expression that satisfy these rules:
- The maximum number of decimal point is 3 but a number with no decimal point (e.g 12) should be accepted too
- the value must be at least 0
- the value must be less or equal to 99999999999.999
- the radix point is DOT (e.g 2.5, not 2,5)
Sample of valid numbers:
0
2
0.4
78784764.23
45.232
Sample of invalid numbers:
-2
123456789522144
84.2564
I found an example here (http://forums.asp.net/t/1642501.aspx) and have managed to modify it a little bit to make 0 as the minimum value, 99999999999.999 as the maximum value and to accept only DOT as radix point. Here’s my modified regex:
^\-?(([0-9]\d?|0\d{1,2})((\.)\d{0,2})?|99999999999.999((\.)0{1,2})?)$
However, I still have problem with the 3 decimal point and it is rather unstable. Can anyone help me on this since I’m basically illiterate when it comes to regex?
Thanks.
EDITED:
I’m using ASP Regular Expression Validator
This is not that difficult:
Explanation: