在 Java 中,兩個(gè)\代表其他語言的一個(gè),所以一位數(shù)字的正則表達(dá)式是\d
通過這個(gè)正則表達(dá)式,有點(diǎn)理解了 ‘^’ 和 ‘&’ 的作用。
public static boolean ishour_utc(String str){
return hourUTCPattern.matcher(str).matches();
}
private final static Pattern hourUTCPattern = Pattern.compile("^\\d{4}-([0][0-9]|[1][0-2])-([0-2][0-9]|[3][0-1])T([0-5][0-9])Z$");