常用正则表达式

1、过滤所有数字

String regEx="[0-9]";

Pattern p=Pattern.compile(regEx);

Matcher m=p.matcher(str);

m.replaceAll("").trim();

2、过滤所有非数字字符

String regEx="[^0-9]";

Pattern p=Pattern.compile(regEx);

Matcher m=p.matcher(str);

m.replaceAll("").trim();

原文地址:https://www.cnblogs.com/maydow/p/5357341.html