RegExp.prototype.ignoreCase

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

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

Try it

const regex1 = /foo/;
const regex2 = /foo/i;

console.log(regex1.test("Football"));
// Expected output: false

console.log(regex2.ignoreCase);
// Expected output: true

console.log(regex2.test("Football"));
// Expected output: true

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. Case-insensitive matching is done by mapping both the expected character set and the matched string to the same casing.

If the regex is Unicode-aware, the case mapping happens through simple case folding specified in CaseFolding.txt. The mapping always maps to a single code point, so it does not map, for example, ß (U+00DF LATIN SMALL LETTER SHARP S) to ss (which is full case folding, not simple case folding). It may however map code points outside the Basic Latin block to code points within it — for example, `RegExp.prototype.lastIndex