The i flag (ignoreCase) makes letter matching case-insensitive. With /hello/i, the pattern matches hello, Hello, and HELLO—ideal for user input and search where case should not matter.
Remember
/pattern/i // ignore letter case
regex.ignoreCase // true when i is set
/hello/i.test("HELLO") → true
/hello/.test("HELLO") → false
digits & symbols: unchanged by i
combine: /error/gi
Create a case-insensitive regex: /pattern/i or new RegExp("pattern", "i").
Call test, match, or replace — letters fold case automatically.
Add g when you need every occurrence: /pattern/gi.
Confirm with regex.ignoreCase when debugging.
Piece
Required?
Role
i flag
Yes
Ignore letter case while matching
g flag
Optional
Find / replace every case variant
Pattern letters
—
Any casing in the pattern is fine with i
Pseudocode
Pseudocode
re = /pattern/i
for each letter in pattern and input:
compare using case fold
(A ≡ a, B ≡ b, …)
digits / symbols:
compare exactly (i has no effect)
if all parts match → success
Reference
Cheat Sheet
Keep these ignoreCase facts handy.
Topic
Detail
Syntax
/pattern/i or new RegExp(p, "i")
Check flag
regex.ignoreCase
With global
/pattern/gi (order does not matter)
Affects
Letters (case fold)
Does not affect
Digits, spaces, punctuation
vs manual classes
/hi/i ≈ /[Hh][Ii]/ (ASCII)
Standard
ES3+ (universal)
Try it
Live Preview
Compare case-sensitive vs case-insensitive matching on sample text.
Browser demo of ignoreCase — same idea as the examples below.
Result
/hello/i.test("Hello")
→ true
/* i folds letter case */
Code
JavaScript Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Collect variants."Error" and "ERROR" both match /error/gi.
Global alone fails./error/g looks for lowercase only → null.
Order free.gi and ig are the same flags.
Example 3 — Case-Insensitive replace
Normalize every spelling of a word with replace and gi.
JavaScript
const text = "I love js and JS and Js";
console.log(text.replace(/js/gi, "JavaScript"));
// "I love JavaScript and JavaScript and JavaScript"
console.log(text.replace(/js/g, "JavaScript"));
// "I love JavaScript and JS and Js" (only lowercase js)
I love JavaScript and JavaScript and JavaScript
I love JavaScript and JS and Js
How It Works
gi replaces all casings.js, JS, and Js all become "JavaScript".
g alone is exact. Without i, only lowercase js is replaced.
New string returned. The original text is unchanged.
Common cleanup. Useful for normalizing tags, brands, or keywords from user input.
Edge Cases & Pitfalls
Check these before relying on ignoreCase.
scope
Letters only
i does not change how digits or punctuation match. /a1/i still requires the digit 1.
unicode
Locale case rules differ
Some languages have special case mappings (e.g. Turkish I/ı). For complex Unicode, consider the u flag and explicit tests.
exact
Do not use i when case matters
Passwords, codes, and case-sensitive IDs should use a regex withouti.
classes
Prefer /word/i over huge classes
Manual /[Ww][Oo]…/ works for ASCII but is harder to maintain than a single i flag.
Compatibility
Browser & Runtime Support
The i (ignoreCase) flag is part of core JavaScript regular expression syntax (ES3+).
✓ Baseline · ES3+
RegExp i / ignoreCase
Supported in every browser and Node.js version. Case-insensitive matching works everywhere.
99%Universal syntax
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
i flagExcellent
Bottom line: Safe everywhere. Use i for flexible letter matching; combine with g when you need every case variant.
Analysis
Performance Notes
Approach
Cost
Best for
/word/i
~same as case-sensitive
Normal case-insensitive checks
/[Ww][Oo]…/
Similar, harder to write
Avoid for long words
toLowerCase() + match
Extra string copy
Fine for short inputs; i is simpler
Case folding is handled by the engine. Prefer /pattern/i over building large character classes or lowercasing the whole string first unless you have a specific reason.
Remember
Key Takeaways
Role:i makes letter matching case-insensitive.
Check:regex.ignoreCase mirrors the flag.
Combo: use gi to find / replace every case variant.
Scope: letters fold; digits and symbols stay exact.
One line: add i when letter case should not matter — and skip it when case is part of the meaning.
Frequently Asked Questions
The i flag (ignoreCase) makes letter matching case-insensitive. /hello/i matches hello, Hello, HELLO, and HeLLo because uppercase and lowercase letters are treated as equivalent.
Append i to the literal: /pattern/i, combine flags like /pattern/gi, or pass 'i' in new RegExp('pattern', 'i'). Then regex.ignoreCase is true.
No. ignoreCase applies to letters. Digits, spaces, and symbols match the same with or without i.
Yes. /error/gi finds every case variant of error in a string. Flag order does not matter: gi and ig are equivalent.
For ASCII letters they match the same strings, but /word/i is shorter and applies case folding to the whole pattern automatically.
The ignoreCase flag is core JavaScript regex syntax since ES3. It works in every browser and Node.js version.