I have this REGEX almost perfect ... It seems to handle everything except a number that leads with a negative sign and then a decimal. So if I enter:
-.2
I get an error -
Here is my Regex -- everything else I've tested works perfectly...
^(\+|-)?[0-9]{1,11}?(?:\.[0-9]{1,4})?$
This allows for:
- a number up to 11 digits (99 Billion)
- positive or negative number
- up to 4 decimal places (optional)
- leading 0 before decimal point is optional - for positive numbers only
These all work:
-0.2345
-10
12
.125
0.1245
5.555
25000000000 (aka 25 Billion)
25000000000.25
These do not work:
-.2
-.421