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
regex asp.net c # -4.0


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


source to share


The regular expression will look like this:

^(:?(:?0\.[0-9])|(:?1\.0))$

      



But why not use a decimal comparison?

+3


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics