The ignoreCase property is true when a RegExp was built with the i flag. That tells JavaScript to treat uppercase and lowercase letters as equivalent—so /hello/i matches "Hello", "HELLO", and "hello".
01
Property
regex.ignoreCase
02
i flag
/pat/i
03
Boolean
true / false
04
Letters
A matches a
05
Combine
gi flags
06
Read-only
Fixed flags
Fundamentals
Introduction
By default, regular expressions are case-sensitive. The pattern /javascript/ matches lowercase "javascript" but not "JavaScript" or "JAVASCRIPT".
The ignoreCase (i) flag removes that restriction for letters. The ignoreCase property reports whether that flag is active. You set it at creation with /pattern/i or new RegExp("pattern", "i"), then read regex.ignoreCase in your code.
Concept
Understanding the ignoreCase Property
RegExp.prototype.ignoreCase is a read-only boolean:
true — the i flag is set; letters match regardless of case.
false — default behavior; A and a are different characters.
Reflects flags — also visible in regex.flags when it contains "i".
Immutable — you cannot flip ignoreCase after construction; create a new RegExp instead.
Letters only — digits, spaces, and punctuation are unaffected by the i flag.
When validating user input like emails or usernames, case-insensitive matching is often what you want. Add i instead of duplicating every letter as [Aa].
Usage
How to Use ignoreCase in JavaScript
Set the flag at creation, then use normal RegExp methods. The engine handles case folding automatically:
JavaScript
const keyword = /warning/i;
keyword.test("WARNING"); // true
"Error and ERROR".match(/error/i); // ["Error"]
"Yes YES yes".replace(/yes/gi, "ok"); // "ok ok ok"
Pair i with g when you need every case-variant match in a string, or with m for multiline text that also ignores case.
Foundation
📝 Syntax
JavaScript
regex.ignoreCase
How to set ignoreCase mode (at creation)
JavaScript
/pattern/i
new RegExp("pattern", "i")
new RegExp("pattern", "gi") // global + ignoreCase
Return value
true if the i flag is present.
false otherwise.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Check ignoreCase flag
regex.ignoreCase
Case-insensitive literal
/hello/i
Find all case variants
str.match(/word/gi)
Replace ignoring case
str.replace(/error/gi, "fixed")
Validate extension
/\.(jpg|png)$/i
See all flags
regex.flags
Compare
📋 Case-Insensitive vs Case-Sensitive
The same pattern with and without the i flag.
ignoreCase: false
/hello/
Exact case
ignoreCase: true
/hello/i
Any case
Manual alt
[Hh][Ee]...
Verbose
gi combo
/pat/gi
All + any case
Hands-On
Examples Gallery
Open DevTools Console (F12) or use Try-it links. Examples show how ignoreCase changes matching for real-world text.
The ignoreCase property on RegExp instances is part of standard JavaScript and is supported in all modern environments.
✓ Baseline · ES3+
RegExp ignoreCase
Supported everywhere RegExp is available. The i flag and ignoreCase property behave consistently across browsers and Node.js.
99%Universal API
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
RegExp.ignoreCaseExcellent
Bottom line: Safe everywhere. Use the i flag whenever letter case should not block a match.
Wrap Up
Conclusion
The ignoreCase property tells you whether a RegExp ignores letter case. Turn it on with the i flag to match Hello, HELLO, and hello with one pattern.
Pair i with g for global case-insensitive scans, and remember that flags are set only at creation time. Next, learn the \b word boundary metacharacter for precise whole-word matching.
Check regex.ignoreCase when debugging dynamic regexes
Prefer /word/i over manual [Ww][Oo]...
Build flags strings like "gi" in new RegExp()
❌ Don’t
Use i for password or secret comparison
Try to toggle ignoreCase after creation
Assume i affects digits or punctuation
Forget g when you need every case variant found
Expect replacement text to mirror original casing automatically
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about RegExp ignoreCase
Match letters regardless of uppercase or lowercase.
5
Core concepts
📝01
i flag
/pat/i
Syntax
🔄02
Property
.ignoreCase
Read
📈03
gi combo
All cases.
Pattern
🛠04
Letters
Only A/a.
Scope
🔒05
Fixed
Read-only.
Flags
❓ Frequently Asked Questions
A read-only boolean on a RegExp instance. It is true when the pattern was created with the i (ignoreCase) flag, meaning letter matching ignores uppercase vs lowercase differences.
Use a literal with i: /pattern/i, or the constructor: new RegExp('pattern', 'i'). The ignoreCase property reflects that flag at creation time.
No. The i flag only affects letters (and some Unicode letter-like characters per the engine). Digits, spaces, and punctuation match the same with or without i.
Yes. Use gi or ig in the flags string: /error/gi matches ERROR, Error, and error everywhere in a string.
Similar for one letter, but ignoreCase applies to the entire pattern. /hello/i is simpler than /[Hh][Ee][Ll][Ll][Oo]/ and scales better for longer words.
No. Flags are fixed when the object is created. To toggle case sensitivity, build a new RegExp with or without i in the flags string.
Did you know?
String methods like includes(), startsWith(), and indexOf() also accept a case-insensitive mode in modern JavaScript, but RegExp with the i flag remains the standard tool when you need full pattern power—groups, anchors, and quantifiers—without caring about case.