javascript match case insensitive code example
Example 1: javascript string search case insensitive
function stringContainsCaseInsensitive(search, subject){
return subject.toLowerCase().indexOf(search.toLowerCase()) !== -1;
}
stringContainsCaseInsensitive("red","We painted the room red.");//true
Example 2: js includes case insensitive
var passedinstring = localStorage.getItem("passedinstring").toLowerCase();
Example 3: javascript case insensitive regex
// It's the 'i' flag at the end of the expression.
/hello world/.test('Hello World'); // False
/hello world/i.test('Hello World'); // True