ignoreCase Property (JScript 5.6)
Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only.
rgExp.ignoreCase
Remarks
The required rgExp reference is an instance of the RegExp object.
The ignoreCase property returns true if the ignoreCase flag is set for a regular expression, and returns false if it is not.
The ignoreCase flag, when used, indicates that a search should ignore case sensitivity when matching the pattern within the searched string.
Example
The following example illustrates the use of the ignoreCase property. If you pass "i" in to the function shown below, all instances of the word "the" are replaced with the word "a", including the initial "The". This is because with the ignoreCase flag set, the search ignores any case sensitivity. So "T" is the same as "t" for the purposes of matching.
This function returns a string with a table that shows the condition of the properties associated with the allowable regular expression flags, g, i, and m. The function also returns the string with all replacements made.
function RegExpPropDemo(flag){
if (flag.match(/[^gim]/)) //Check flag for validity.
return("Flag specified is not valid");
var r, re, s //Declare variables.
var ss = "The man hit the ball with the bat.\n";
ss += "while the fielder caught the ball with the glove.";
re = new RegExp("the",flag); //Specify the pattern to search for.
r = ss.replace(re, "a"); //Replace "the" with "a".
s = "Regular Expression property values:\n\n"
s += "global ignoreCase multiline\n"
if (re.global) //Test for global flag.
s += " True ";
else
s += "False ";
if (re.ignoreCase) //Test ignoreCase flag.
s += " True ";
else
s += "False ";
if (re.multiline) //Test multiline flag.
s += " True ";
else
s += " False ";
s += "\n\nThe resulting string is:\n\n" + r;
return(s); //Returns replacement string
}
Requirements
Applies To: Regular Expression Object (JScript 5.6)
See Also
Reference
global Property (JScript 5.6)
multiline Property (JScript 5.6)
Regular Expression Syntax (Scripting)