Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make .find non case sensitive

I can currently using:

$results.find('a[href$=".doc"]')

to find anything ending with .doc for editing reasons. However, this seems to be case sensitive, i.e. if a document ends with .DOC or .Doc, it will not find those. Is it possible to make this non case sensitive?

like image 607
oshirowanen Avatar asked May 17 '26 04:05

oshirowanen


1 Answers

You have to create a function to match case insensitively.

$results.find('a').filter(function(){return /\.doc$/i.test(this.href);});

It is also possible to enumerate all 8 cases in the selector, but this won't scale easily.

$results.find('a[href$=".doc"],a[href$=".doC"],a[href$=".dOc"],a[href$=".dOC"],a[href$=".Doc"],a[href$=".DoC"],a[href$=".DOc"],a[href$=".DOC"]')
like image 138
kennytm Avatar answered May 19 '26 17:05

kennytm