The i modifier (ignoreCase flag) makes letter matching case-insensitive. With /hello/i, the pattern matches hello, Hello, and HELLO—ideal for user input, search boxes, and validation where letter case should not matter.
01
i flag
ignoreCase
02
A = a
Letters only
03
/pat/i
Syntax
04
gi
Global + i
05
test()
Any case
06
vs [Aa]
Simpler
Fundamentals
Introduction
By default, regular expressions distinguish uppercase from lowercase. The letter A in a pattern matches only capital A, not a. The i modifier removes that restriction for letters throughout the pattern.
Case-insensitive matching is one of the most common regex needs in web apps—search fields, filtering lists, validating emails or keywords where users may type any combination of upper and lower case letters.
Concept
Understanding the i Modifier
Append i to a regex literal or pass "i" in constructor flags. The RegExp instance sets ignoreCase: true, and the engine folds letter case during matching.
Digits, whitespace, and punctuation are unaffected. Only letters (and Unicode letter-like characters) participate in case folding.
💡
Beginner Tip
When validating user-typed words, add i instead of listing every case variant: /submit/i beats /[Ss][Uu][Bb][Mm][Ii][Tt]/.
Usage
How to Use the i Modifier
Enable case-insensitive matching on literals, constructors, and combined flags:
JavaScript
/hello/i; // case-insensitive literal
new RegExp("hello", "i"); // constructor
/error/gi; // global + ignoreCase
re.ignoreCase; // true when i is set
text.replace(/yes/gi, "ok"); // replace all case variants
Pair i with g when you need every case-insensitive match in a string, not just the first one.
Foundation
📝 Syntax
JavaScript
/pattern/i // ignoreCase
/pattern/gi // global + ignoreCase
/pattern/ig // same (order free)
new RegExp("p", "i") // constructor
regex.ignoreCase // true | false
Common patterns
/word/i — match word in any letter case.
/error/gi — find every error/ERROR/Error in text.
/^[a-z]+$/i — letters only, any case (still matches A–Z via i).
re.ignoreCase — check whether the flag is active.
Cheat Sheet
⚡ Quick Reference
Goal
Pattern / API
Case-insensitive match
/pattern/i
Check flag
regex.ignoreCase
All case variants
/pat/gi
Replace any case
str.replace(/pat/gi, "x")
Case-sensitive (default)
/pattern/ (no i)
Constructor form
new RegExp("pat", "i")
Compare
📋 With i vs without i
Same pattern, different case sensitivity.
Case-sensitive
/hello/
Exact letter case
ignoreCase
/hello/i
Any letter case
Manual class
[Hh][Ee]...
Verbose alternative
Global + i
/pat/gi
All + any case
Hands-On
Examples Gallery
Open DevTools Console (F12) or use Try-it links. Examples cover test(), ignoreCase, gi combo, replace, and comparison with character classes.
📚 Getting Started
Match text regardless of letter case.
Example 1 — Case-Insensitive test()
Compare /hello/i with the default case-sensitive pattern.
For case-sensitive matching, omit i or use explicit character classes.
Compatibility
Browser & Runtime Support
The i ignoreCase modifier is part of core JavaScript regular expression syntax.
✓ Baseline · ES3+
RegExp i flag
Supported in every browser and Node.js version. The i flag enables case-insensitive letter matching.
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
iExcellent
Bottom line: Safe everywhere. Use i when letter case should not affect whether a pattern matches.
Wrap Up
Conclusion
The i modifier makes regex letter matching case-insensitive. Add it when users may type any mix of uppercase and lowercase, and combine with g to find or replace every case variant in a string.
Prefer /word/i over long manual character classes, remember that digits and symbols are unaffected, and keep patterns case-sensitive when it matters (passwords, encoded data). Next, learn the m multiline modifier.
Five things to remember about the RegExp i modifier
Match letters without worrying about uppercase vs lowercase.
5
Core concepts
📝01
i flag
ignoreCase.
Syntax
📈02
A = a
Letters.
Behavior
🚫03
gi
All + any case.
Combine
🔒04
/pat/i
Search.
Use case
🔢05
No i
Passwords.
Caution
❓ 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'). The ignoreCase property on the instance becomes true.
No. ignoreCase applies to letters (and Unicode letter categories per the engine). 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 insensitivity to the entire pattern automatically, including character classes and groups.
The ignoreCase flag is core JavaScript regex syntax since ES3. It works in every browser and Node.js version.
Did you know?
HTML search inputs often feel case-insensitive because the browser or your JavaScript adds an i flag behind the scenes. When you write your own filter with regex, you must add i explicitly—/query/ alone will not match Query.