How would I make the following case insensitive?
if ($(this).attr("href").match(/\.exe$/))
{
// do something
}
How would I make the following case insensitive?
if ($(this).attr("href").match(/\.exe$/))
{
// do something
}
Unlike the match() function, the test() function returns true or false and is generally preferred when simply testing if a RegEx matches. The /i modifier for case insensitive matching works with both functions.
Example using test() with /i:
const link = $('a').first();
if (/\.exe$/i.test(link.attr('href')))
$('output').text('The link is evil.');

Fiddle with the code:
https://jsfiddle.net/71tg4dkw
Note:
Be aware of evil links that hide their file extension, like:
https://example.com/evil.exe?x=5
Documentation for test():
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test