Pattern pattern = Pattern.compile("([0-2][0-9])\\:([0-6][0-9])\\:([0-6][0-9])"); Matcher matcher = pattern.matcher("23:01:59"); matcher.matches(); //这一步必须有 否则报错 String result1 = matcher.group(1); String result2 = matcher.group(2); String result3 = matcher.group(3); System.out.println(result1 + " " + result2 + " " + result3 + " ");
测试里碰上一29:69:69的时间怎么办?
Sign in to make a reply
原来是图图呀198009