Saturday, December 28, 2024
Google search engine
HomeLanguagesJavascriptJavaScript RegExp ignoreCase Property

JavaScript RegExp ignoreCase Property

The RegExp ignoreCase property in JavaScript is used to specify whether the “i” modifier is set or not. If the “i” modifier is set than this property returns true otherwise returns false.
Syntax: 

RegexObj.ignoreCase

Return Value: It returns true if i modifier is set, else false.

Example 1: This example checks if the regular expression contains i Modifier or not.  

Javascript




function geek() {
    let regex = new RegExp('foo', 'i');
    console.log(regex.ignoreCase);
}
geek()


Output

true

Example 2: This example checks the regular expression contains i Modifier or not.  

Javascript




function geek() {
    let regex = /[a-d]/;
    let str =
        "neveropen\n" +
        "is the computer\n" +
        "science portal for neveropen.";
 
    if (regex.ignoreCase) {
        console.log("i Modifier is present");
    } else {
        console.log("i Modifier is absent.");
    }
}
geek()


Output

i Modifier is absent.

Supported Browsers: The browsers supported by JavaScript ignoreCase property are listed below: 

  • Google Chrome 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Internet Explorer  5.5 and above
  • Opera 5 and above
  • Safari 1 and above

We have a complete list of Javascript RegExp expressions, to check those please go through this JavaScript RegExp Complete Reference article.

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.  

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments