Table of Contents

Regex - Numbers - Floating-point

Floating-point

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

Positive floating-point

^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$

or

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

Negative floating-point

^((-\d+(\.\d+)?)|(0+(\.0+)?))$

or

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

or

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

or

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