目前就总结了校验 日期(没有考虑闰年,大小月情况),数字,字符串和其他字符的组合等
/**
* 校验日期格式
* @param str YYYY-MM-DD
* @return
*/
private boolean checkDate(String str){
if(isNull(str)){
return false;
}
Pattern p = Pattern.compile("^2\\d{3}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$");
Matcher m = p.matcher(str) ;
return m.matches();
}
/**
* 校验航班号
* @param str 长度为6, 头部为HO,后4位 3位 + 字母 或4位数字
* @return
*/
private boolean checkFlightNo(String str){
if(isNull(str)){
return false;
}
if(str.length() > 6){
return false;
}
Pattern p_flgt = Pattern.compile("^[0-9]{3}