December 2013
Intermediate to advanced
384 pages
9h 54m
English
var s1 = "jQuery, sometimes JQuery or JQUERY"; var s2 = s1.replace(/jQuery/gi, "jQuery"); //s2 is now "jQuery, sometimes jQuery or jQuery"
The best way to find and replace substrings while ignoring case is to use a regular expression in the .replace() method. If you are not familiar with them, I’d suggest you at least look into them. They can use complex formulas for finding matches in strings. For now, I’ll just show you a simple expression.
As an example, to find all instances of the term jQuery when you may not know the case specified in the string, you would define the following regular expression. The g character specifies a global search (meaning not to ...
Read now
Unlock full access