I need a regular expression that should validate decimal point as well as range. Totally 3 number should be present including dot and the value must be greater than 0.0. That means the valid range is from 0.1 to 7.0.
I used the following regex: ^\\d{1,1}(\\.\\d{1,2})?$
It works fine except for the range validation. What do I need to change?
To complete the great @TimPietzcker answer,
this Regex...
also match:
for anyone who needs it !
Regexes are notoriously bad at validating number ranges. But it's possible. You have to break down the number range into the expected textual representations of those numbers:
As a one-liner:
In Java: