I look for a regular expression to support double number with just one fraction part which ranges between 0.1 to 999.9
It means following values are not allowed:
0
0.0 // less than lower bound
0.19 // fraction part is 2 digits, right '9' is extra
94.11 // fraction part is 2 digits, right '1' is extra
999.90 // fraction part is 2 digits, '0' is extra
9.0 // should be 9 or 9.1, 9.0 is wrong
1000 // is higher than upper bound
allowed ones:
1.1
55.5
999.9
My regular expression is:
(^(\.[1-9])?$|(^[1-9][0-9]{0,2}?(\.[1-9])?$))$
Which doesn't support 0.1
to 0.9
and extra zeros like 99.000
and 99.0
Test steps: In your browser console:
var reg = new RegExp(/(^(\.[1-9])?$|(^[1-9][0-9]{0,2}?(\.[1-9])?$))$/);
reg.test(12);
Any help appriciated