Quite a few ways to do this...
string.matches("[0-9]*[\\.]*[0-9]+")
Uses a regular expression which should validate an integer or floating point number. You could do the same thing for words:...