Regular expression to define a decimal number from 0.0 to 1.0
I'm looking for a regex check expression to test if a decimal value (x) has the following: 0.0 <= x <= 1.0
Only one decimal place is allowed. How to do it?
thank
+3
Rifaz Rifky
source
to share
2 answers
Try this, it will check one decimal place instead of other suggested options
^((0\.[0-9]{1})|(1\.0))$
+4
Dis Shishkov
source
to share
The regular expression will look like this:
^(:?(:?0\.[0-9])|(:?1\.0))$
But why not use a decimal comparison?
+3
Chris seymour
source
to share