* @author:Avery
* @description:截取字符串中所有數字轉爲int 如:"dafe@fd00123dfd456"轉爲00123456轉爲int 123456
* @date:2017年7月15日
*/
public class Intercept {
public static int testIntercept(String str) {
str = str.replaceAll("[^\\d+]", "");// 用""替換所有的非數字 字符
return Integer.parseInt(str);// 將數字字符轉爲int
}
String str = "abc0123-*45$dfd78";
System.out.println(testIntercept(str));// 1234578
}
}