ignore lowercase or uppercase nodejs string code example

Example 1: js ignore case

var str = "Visit W3Schools!";
var patt1 = /W3S/i;
var res = patt1.ignoreCase

Example 2: compare string camelcase and lowercase javascript

function sameCase(str) {
  return /^[A-Z]+$/.test(str) || /^[a-z]+$/.test(str);
}

Example 3: 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
}