int x = Integer.parseInt("abcd123546fde".replaceAll("[a-zA-Z]",""));
我来捣乱的 :) String out = ""; String str = "abcd123546fde"; for (char i : str.toCharArray()) { if ((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z')) { continue; } out += i + ""; } System.out.println(out);
String str = "abcd123546fde";
str = str.replaceAll("[^0-9]","");
String str = "abcd123546fde";
for (char i : str.toCharArray()) {
if ((i >= 'a' && i <= 'z')
|| (i >= 'A' && i <= 'Z')) {
continue;
}
out += i + "";
} System.out.println(out);