RegExp.prototype.ignoreCase

The ignoreCase accessor property of RegExp instances returns whether or not the i flag is used with this regular expression.

Try it

Description

RegExp.prototype.ignoreCase has the value true if the i flag was used; otherwise, false. The i flag indicates that case should be ignored while attempting a match in a string.

If the regex has the unicode flag, the case mapping happens as specified in CaseFolding.txt. Otherwise, case mapping uses the Unicode Default Case Conversion — the same algorithm used in String.prototype.toUpperCase() and String.prototype.toLowerCase().

The set accessor of ignoreCase is undefined. You cannot change this property directly.

Examples

Using ignoreCase

const regex = /foo/i;

console.log(regex.ignoreCase); // true

Specifications

Specification
ECMAScript Language Specification
# sec-get-regexp.prototype.ignorecase

Browser compatibility

BCD tables only load in the browser

See also