views:

34

answers:

2

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?

+7  A: 

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"]')
KennyTM
+1 - This is your best bet, making another attribute selector isn't pretty, and won't be as efficient either.
Nick Craver
ouch. I assume it works, but that ain't pretty code.
Spudley
A: 

try this i am not sure :

$results.find("a:regex(href, /\.doc$/i)")

but this will work for all a tags so u can use it with $results somehow

$("a:regex(href, /\.doc$/i)")

http://api.jquery.com/category/selectors/

jknair