package rbq.codedemo;
import java.util.regex.Pattern;
/**
* Created by rbq on 2016/12/13.
*/
public class NumUtils {
public static boolean isNum(String str){
Pattern pattern = Pattern.compile("^-?[0-9]+");
if(pattern.matcher(str).matches()){
//数字
return true;
} else {
//非数字
return false;
}
}
public static boolean isNum1(String str){
//带小数的
Pattern pattern = Pattern.compile("^[-+]?[0-9]+(\.[0-9]+)?$");
if(pattern.matcher(str).matches()){
//数字
return true;
} else {
//非数字
return false;
}
}
}