I have the following file name:
ABC 14-15 PCEE qwerty checklist - checked by XYZ IDFFCFYYL-01 BB.xlsx
I am using the following regex to test whether the file has XLSX
extension:
String filename = "ABC 14-15 PCEE qwerty checklist - checked by XYZ IDFFCFYYL-01 BB.xlsx";
private static final String checkXLSXfile = "([^\\s]+(\\.(?i)(xlsx))$)";
private static final Pattern pattern = Pattern.compile(checkXLSXfile);
if (pattern.matcher(filename).matches()) {
System.out.println("Heaven");
}
else {
System.out.println("HELL");
}
However, the pattern fails for this file name. Can anyone help me resolve this?