Use String#end_with?() but ignore case

regex, ruby, string

Solution

Change filename to lowercase and compare with lowercase extensions.

filename.downcase.end_with?(*%w(.ext1 .e2 .extension))
'MAIN.RB'.downcase.end_with?(*%w(.ruby .rb)) # => true

Problem

How to determine if string ends with another string regardless of its case? ``` filename.end_with?(*%w(.ext1 .e2 .extension)) ``` This example only matches if the case matches too. How to match regardless of the case?

Original source