Try this:
^X-?((\d+)|(\d+\.\d*)|(\.\d+))$
^X-?
Beginning of line or string
X-, zero or one repetitions
[1]: A numbered capture group. [(\d+)|(\d+\.\d*)|(\.\d+)]
Select from 3 alternatives
[2]: A numbered capture group. [\d+]
Any digit, one or more repetitions
[3]: A numbered capture group. [\d+\.\d*]
\d+\.\d*
Any digit, one or more repetitions
Literal .
Any digit, any number of repetitions
[4]: A numbered capture group. [\.\d+]
\.\d+
Literal .
Any digit, one or more repetitions
End of line or string