Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

javascript
community creator

What is ignorecase?

Mohammad Razi ul Haq

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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 RegExpRegular Expression objects.

Code

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 Football
console.log(r2.ignoreCase);
// Returns true since ignoreCase property is set to True
console.log(r2.test('Barricade'));
// Returns true since it detects bar in Barricade by
// ignoring the case

RELATED TAGS

javascript
community creator

CONTRIBUTOR

Mohammad Razi ul Haq

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring