Java regex for XLSX file extension -


i have following file name:

abc 14-15 pcee qwerty checklist - checked xyz idffcfyyl-01 bb.xlsx

i using following regex test whether file has xlsx extension:

string filename = "abc 14-15 pcee qwerty checklist - checked 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, pattern fails file name. can me resolve this?

why not use string.endswith(string) method?

if(filename.tolowercase().endswith(".xlsx")) {  // } else {   // else } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -