取一串数字中的数字串

Pattern p = Pattern.compile("\d{2,}");//这个2是指连续数字的最少个数
String u = "abc435345defsfsaf564565fsabad5467755fewfadfgea";
Matcher m = p.matcher(u);
int i = 0;
while (m.find()) {
System.out.println(m.group());
i++;
}
System.out.println(i);

你可能感兴趣的:(取一串数字中的数字串)