The ignoreCase
property in Javascript specifies if the Regular expression will perform case-insensitive matching when comparing two strings.
The property returns True
or False
based on the value of the i
attribute of
If the i
attribute is set to True
, the regular expression will infer “ABC” and “aBc” as the same strings.
const r1 = new RegExp('foo');const r2 = new RegExp('bar', 'i');console.log(r1.test('Football'));// Returns false since ignoreCase property is not set.// Hence it does not detect foo in Footballconsole.log(r2.ignoreCase);// Returns true since ignoreCase property is set to Trueconsole.log(r2.test('Barricade'));// Returns true since it detects bar in Barricade by// ignoring the case