'Check if a string ends with something, case insensitive?

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?



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PMunch