ES6 - RegExp ignoreCase



ignoreCase is a read-only boolean property of RegExp objects. It specifies whether a particular regular expression performs case-insensitive matching, i.e., whether it was created with the "i" attribute.

Syntax

RegExpObject.ignoreCase         

Return Value

Returns "TRUE" if the "i" modifier is set, "FALSE" otherwise.

Example

var re = new RegExp( "string" ); 

if ( re.ignoreCase ){ 
   console.log("Test1-ignoreCase property is set");  
} else { 
   console.log("Test1-ignoreCase property is not set");  
} 
re = new RegExp( "string", "i" ); 

if ( re.ignoreCase ) {
   console.log("Test2-ignoreCase property is set");  
} else { 
   console.log("Test2-ignoreCase property is not set");  
}

Output

Test1-ignoreCase property is not set 
Test2-ignoreCase property is set      
Advertisements