//从字符串中获取数字 public static String getNum(String str) { String dest = ""; if (str != null) { dest = str.replaceAll("[^0-9]",""); } return dest; } //从字符串中过滤数字 public static String removeNum(String str) { String regEx = "[0-9]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); //替换与模式匹配的所有字符(即数字的字符将被""替换) return m.replaceAll("").trim(); }