Saturday, June 1, 2024
 Popular · Latest · Hot · Upcoming
192
rated 0 times [  196] [ 4]  / answers: 1 / hits: 78240  / 15 Years ago, fri, august 7, 2009, 12:00:00

I am trying to find if an image has in its source name noPic which can be in upper or lower case.



var noPic = largeSrc.indexOf(nopic);


Should I write :



var noPic = largeSrc.toLowerCase().indexOf(nopic);


But this solution doesn't work...


More From » javascript

 Answers
189

You can use regex with a case-insensitive modifier - admittedly not necessarily as fast as indexOf.



var noPic = largeSrc.search(/nopic/i);

[#98963] Tuesday, August 4, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
estefanib

Total Points: 508
Total Questions: 104
Total Answers: 83

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;