I need to check if the user input is a string or a number.
I use the below statement for the purpose,
Double.parseDouble(string);
It works in most of the scenarios, but fails when the input entered by the user is like 123F
This should be considered as a string however the above case considers it as a number. I even tried using
NumberUtils.isNumber(string);
but still the behaviour is same.
I tried the following regex pattern which works
"-?\\d+(\\.\\d+)?"
However is there any other alternate api for the same.