Import Java.util.regex.Matcher;
Import Java.util.regex.Pattern;
public class Testregex {
public static void Main (string[] args) {
Time Regular expression
String reg = "(. *)-(. *) (. *):(. *)";
String REG2 = "(. *) (0[1-9]|1[1-2])/(0[1-9]|[ 1-2]\\D|3[0-1]) ([0-2][0-9]):([0-5]\\d] (. *) ";
Pattern pattern = pattern.compile (REG2);
Time string
String timestr = "(06/06 15:50)";
Matcher Matcher = Pattern.matcher (TIMESTR);
while (Matcher.find ()) {
for (int i = 1;i<=matcher.groupcount (); i++) {
System.out.println (Matcher.group (i));
}
}
}
}
/*
* * Regular: (Today | (. *) month ([0-2][0-9]):([0-5]\\d]
Time: Today 17:19 or June 1 09:53
*
* Regular: (\\d{4})-(0[1-9]|1[1-2])-(0[1-9]|[ 1-2]\\D|3[0-1]) ([0-2][0-4]):([0-5]\\d):([0-5]\\d]
Time: 2016-05-23-23:35:41
*
* Regular: (0[1-9]|1[1-2])-(0[1-9]|[ 1-2]\\D|3[0-1]) ([0-2][0-9]):([0-5]\\d]
Time: 05-04 06:33
Regular: (. *) (0[1-9]|1[1-2])/(0[1-9]|[ 1-2]\\D|3[0-1]) ([0-2][0-9]):([0-5]\\d) (. *)
Time: (06/06 15:50)
* */
JAVA.UTIL.REGX Demo