I've written two Regexp's that allow for the following formats:
- X
- X.
- X.Y
Where Y can be 1 or 2 digits. And X is unlimited.
Regex1: ^\d+(?:\.{0,1})(?:\d{1,2})?$
Regex2: ^\d+\.{0,1}(?:\d{1,2})?$
Is one better than the other?
Is there a better way to write this?
Also, why doesn't this one work where the dot is just set as optional: ^\d+(?:\.)(?:\d{1,2})?$
Thanks.