Regular Expressions
code show as below:
public static boolean isNum(String num){
return num.matches("(\\s)*([+-])?(([0-9]*\\.)?([0-9]+)|([0-9]+)(\\.[0-9]*)?)([eE][\\+-]?[0-9]+)?(\\s)*");
}
Abnormal use of BigDecimal
public static boolean isNum(String str){
try {
BigDecimal num = new BigDecimal(str);
}catch (Exception e){//抛异常必定不是数字
return false;
}return true;
}
Determining whether the character is a digit
Character.isDigit(ch)
Determining whether the character is a letter
boolean isLetter(char ch)