日期:2014-05-18 浏览次数:20916 次
public static void main(String[] args) {
String ss="aa123bb";
Pattern p=Pattern.compile("\\d+");
Matcher m=p.matcher(ss);
while(m.find()){
System.out.println(m.group());
}
}
public class Aloha {
public static void main(String[] args) {
String[] strs = {"aaa123bbb", "aaa234bbb", "aaa567bbb", "345", "267"};
String pattern = ".*?(\\d+).*";
for (String str : strs) {
System.out.println(str.replaceAll(pattern, "$1"));
}
}
}