// **********************************
// **函数名:isNumber
// **功 能:判断字符串是否只包含数字
// **参 数:String
// **返回值:boolean
// ***********************************
public boolean isNumber(String s) {
boolean bl = false;
s = "2244434245460KIP";
//匹配正整数
String str = null; //这里不会写了,请告诉我判断数字的正则表达式子 谢谢!!
Pattern p = Pattern.compile(str);
Matcher match = p.matcher(s);
if (match.find()) {
return !bl;
} else {
return bl;
}
}
public static void main(String[] args) {
String s = "24443424546";
String str = "[a-zA-Z]+";
Pattern p = Pattern.compile(str);
Matcher match = p.matcher(s);
if (match.find()) {
System.out.println("Not Number");
} else {
System.out.println("Number");
}
}
boolean bl = false;
s = "2244434245460KIP";
//匹配正整数
String str = "\\d+" Pattern p = Pattern.compile(str);
Matcher match = p.matcher(s);
if (match.find()) {
return !bl;
} else {
return bl;
}
}
boolean bl = false;
s = "2244434245460KIP";
//匹配正整数
String str = "\\d+" ;
Pattern p = Pattern.compile(str);
Matcher match = p.matcher(s);
if (match.find()) {
return !bl;
} else {
return bl;
}
}
public static void main(String[] args){
String s = "2244434245460KIP";
boolean bl=Pattern.matches("\\b+",s);
if(bl){
System.out.println("您输入的字符串只包含数字");
}
else{
System.out.println("您输入的字符串不是只包含数字");
}
}
}