import java.util.regex.*; public class Test { public static void main(String[] args) { String regex = "([01]\\d|2[0-3])\\:([0-5]\\d)\\:([0-5]\\d)"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher("00:00:00"); if (matcher.matches()) { String s1 = matcher.group(1); String s2 = matcher.group(2); String s3 = matcher.group(3); System.out.println(s1); System.out.println(s2); System.out.println(s3); } else { System.out.println("失败"); } } }
Sign in to make a reply
征服天堂jj