in reply to Re^2: Floating Point/Integer Regular Expression
in thread Floating Point/Integer Regular Expression
Did you know that regexp matches:
But fails to match:
You might want to try this. It's somewhat simpler than yours, and it disallows the single hyphen, but allows decimals which start with the decimal point and no preceding 0.
/^[-]?(?:[.]\d+|\d+(?:[.]\d*)?)$/
Or if you consider a leading/trailing decimal point to be an error, it can be made simpler:
/^[-]?\d+(?:[.]\d+)?$/
|
|---|