Regular expression to match decimals with or without leading zeros

regex

Solution

Just change the `+` after `[0]` into an ansterisk `*":

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

So instead of allowing one or more zeroes preceding the dot, just allow 0 or more.

Problem

``` ^([0-9]*[1-9][0-9]*(\.[0-9]+)?|[0]+\.[0-9]*[1-9][0-9]*)$ ``` I don't know regular expression well. Above regular expression does not allow input .2 .but it allows all other decimals like 0.2 , 0.02 etc . I need to make this expression allow the number like .2 ,.06 , etc.....

Original source