要求很简单,直接上代码
String a="liu847yan064zhao370";
String regEx="[^0-9]";
//方法一(需要导入regex类)
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(a);
System.out.println(m.replaceAll(""));//847064370
//方法二、
System.out.println(a.replaceAll(regEx, ""));//847064370
本文地址:http://liuyanzhao.com/2898.html
转载请注明。