string match case insensitive javascript code example
Example 1: equalsignorecase typescript
const str1 = '[email protected]';
const str2 = '[email protected]';
str1 === str2; // false
str1.toLowerCase() === str2.toLowerCase(); // true
Example 2: 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) {
// Your code here
}