Home > database >  Check if a string ends with something, case insensitive?
Check if a string ends with something, case insensitive?

Time:04-21

I want to check if a file has a certain extension, which I can do with filename.endsWith(".ext"). But I also want to match against .EXT. How can I do this?

CodePudding user response:

The easiest is probably filename.toLowerAscii.endsWith(".ext"). You should however consider using splitFile to get the extension and then simply compare it to ".ext" after turning it lowercase.

  • Related