I'm trying to write a regular expression to match both positive and negative floating points of any length of characters. I tried this
/^-|[0-9\ ]+$/
However this is still wrong because for example it would match "46.0" and "-46.0" but will also match "4-6.0" which I don't want.
At the moment i'm using this
/^-|[0-9][0-9\ ]+$/
This fixes the first problem but this will match something like "-4g" and that is also incorrect.
What expression can I use to match negative and positive floating points?