利用正则表达式匹配字母,然后替换
public class Test {
public static void main(String[] args) {
String str = "asdasasdkdlsdaa668*)(^%*YTILKHqwe12345jfkhkab";
str = str.replaceAll("[a-zA-Z]","" );
System.out.println(str);
}
}
输出的结果:
668*)(^%*12345