java怎么判断字符串中是否有数字?怎么去除字符串中的数字?
1.判断字符串中是否有数字:
String s = "升降机123"
if(isNumeric(s)){
}
public static boolean isNumeric(String str) {
Pattern pattern = Pattern.compile(".*[0-9].*");
return pattern.matcher(str).matches();
}
2.去除字符串中的数字
String s = "升降机123"
s= s.replaceAll("\\d+", "");

浙公网安备 33010602011771号