js compare string ignore case code example
Example 1: Javascript case insensitive string comparison
var name1 = "Taylor Johnson";
var name2 ="taylor johnson";
if(name1.toLowerCase() === name2.toLowerCase()){
}
Example 2: equalsignorecase typescript
const str1 = '[email protected]';
const str2 = '[email protected]';
str1 === str2;
str1.toLowerCase() === str2.toLowerCase();
Example 3: js ignore case
var str = "Visit W3Schools!";
var patt1 = /W3S/i;
var res = patt1.ignoreCase
Example 4: compare string camelcase and lowercase javascript
var haystack = "A. BAIL. Of. Hay.";
var needle = "bail.";
var needleRegExp = new RegExp(needle.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), "i");
var result = needleRegExp.test(haystack);
if (result) {
}