I want a regular expression that will accept only floating point numbers from 0 to 9 and minus sign.
Please help.
^[-+]?[0-9]*\.?[0-9]+$
^ - start of string[-+]? - 0 or 1 sign indicator[0-9]* - 0 or more integers\. - the character . (. is used in regex to mean "any character")[0-9]+ - 1 or more integers$ - the end of the stringIf you are instead using the comma as a decimal seperator, use , instead of \.
If you are using both/either, you can use [.,]