For example: 10 0.1 1.23234 123.123 0.000001 1.000 .3
And wrong examples: 0001.2 -12 -1.01 +2.3
EDIT: standart JavaScript regex.
Try this here
^(?:[1-9]d*|0)?(?:.d+)?$
See it here online on Regexr
If matching the empty string is not wanted, then you can add a length check to your regex like
^(?=.+)(?:[1-9]d*|0)?(?:.d+)?$
The positive lookahead (?=.+) ensures that there is at least 1 character
(?=.+)
1.4m articles
1.4m replys
5 comments
57.0k users