regular expression in javascript if condition to match the case insensitive string 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.");
Example 2: how to compare strings in javascript ignoring case sensitive
const str1 = '[email protected]';
const str2 = '[email protected]';
str1 === str2;
str1.toLowerCase() === str2.toLowerCase();