The correct way for this problem is not to use a regex, but simply use:
try { Float.parseFloat(string) return true; } catch (NumberFormatException ex) { return false; }
Works fine, this is the same code that is later used to parse the float and therefore the error (or if we don't have a much more serious problem).
source share