正则表达式校验(工具类)
public class PatternHelper {
private final static String EXP_A_Z_ALL = "[a-zA-Z]*";
public static boolean chkAllLetter(String str){
if(chkUtil.isEmpty(str)){
return true;
}
pattern p = Pattern.compile(EXP_A_Z_ALL);
Matcher m = p.matcher(str)
return m.matches();
}
public static boolean chkPattern(String pat , String str){
if(chkUtil.isEmpty(pat) || chkUtil.isEmpty(str)){
return true;
}
pattern p = Pattern.compile(pat);
Matcher m = p.matcher(str)
return m.matches();
}
public static boolean chkPattern(String pat , String str){
if(chkUtil.isEmpty(pat) || chkUtil.isEmpty(str)){
return true;
}
pattern p = Pattern.compile(pat);
Matcher m = p.matcher(str)
return m.find();
}
public static boolean chkExcel(String fileName) {
if (ChkUtil.isEmpty(fileName)) {
return false;
}
if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) {
return false;
}
return true;
}
}