I am working on a requirement where the input should only accept decimal characters, negative or positive. I need to use regex to make the decimal point mandatory, however it is currently allowing negative whole numbers which is not the desired behavior. It should also not accept positive whole numbers (e.g. -2 should be accepted but 2 should not be). Both -2.0 and 2.0 should be allowed.
My current regex is '^([^A-Za-z]-?[0-9].[0-9])$' which ensures there are no letters, makes the '-' character optional, and requires the '.' character (but only for positive numbers). I now need to modify the regex so that the decimal point is mandatory for negative decimals as well.