public static boolean judgeContainNumber(String str){ Pattern p = Pattern.compile(".*\\d+.*"); Matcher m = p.matcher(str); if (m.matches()){ System.out.println("有数字"); return true; }else { System.out.println("没有数字"); } return false;}