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;
}
}
}