ringa_lee2017-04-18 10:47:47
String s = "杭州20170222ax";
Pattern p = Pattern.compile("([0-9].{5,5})");
Matcher m = p.matcher(s);
m.find();
System.out.println(m.group(1));
阿神2017-04-18 10:47:47
Traverse the string, str.charAt(i)>=48 && str.charAt(i)<=57 to determine the number, the first one that meets the requirements is the subscript
大家讲道理2017-04-18 10:47:47
System.out.println( new Scanner("宁波20170222呵呵22").useDelimiter("\D+").nextInt());
迷茫2017-04-18 10:47:47
String s = "杭州20170222ax";
char[] chars = s.toCharArray();
for (int i = 0; i < chars.length; i++) {
if (Character.isDigit(chars[i])) {
System.out.println(s.substring(i, i + 6));
break;
}
}