1.使用正则删除非数字
str = str.replaceAll("\\D+","");
2.Google Guava
CharMatcher.inRange('0','9').retainFrom("123-456-789")
或
String input = "My phone number is 123-456-789!";
String output = CharMatcher.is('-').or(CharMatcher.DIGIT).retainFrom(input); // output 123-456-789
最新评论
怎么取消了蓝奏云分享啊,请继续用蓝奏云啊……
哦 谢谢 那我试试
有木马
下载不了了