[abc] is a character class that matches one character from a custom set — here a, b, or c. Order inside the brackets does not matter.
Remember
/[abc]/ → one of: a, b, or c
/[abc]+/ → one or more from that set
/[abc]/i → case-insensitive (also A, B, C)
[abc] ≠ (abc)
set of one char vs literal "abc"
List the allowed characters inside [ ], then test or extract.
Put the allowed characters between square brackets: [abc].
Add a quantifier (+, {n}) if you need more than one match in a row.
Use test() for yes/no, or exec() / match() to read the character.
Remember: this is a set, not the word "abc" — use (abc) for that sequence.
Piece
Required?
Role
[abc]
Yes
Matches one character from the set
Quantifier
Optional
+, {2}, etc. for length
i flag
Optional
Ignore case for the letters
Pseudocode
Pseudocode
pattern = /[abc]/ // or /[abc]+/, /[abc]/i
str = text to check
if pattern.test(str):
// at least one of a, b, c found
match = pattern.exec(str)
// match[0] is the character (or run)
Reference
Cheat Sheet
Keep these patterns handy while matching a small set of characters.
Pattern
Matches
/[abc]/
One of a, b, c
/[abc]+/
One or more from that set
/[abc]/i
Also A, B, C
/^[abc]$/
Whole string is one of those letters
/[a-z]/
Any lowercase letter (range)
/[^abc]/
One character that is not a, b, or c
Try it
Live Preview
Pick a sample string and see whether /[abc]/ finds a match.
Default is case-sensitive. Without i, A would not match [abc].
i flag./[abc]/i also accepts A, B, and C.
Apple. The leading A matches → true.
Still a set. Letters outside a/b/c (and A/B/C) still fail.
Edge Cases & Pitfalls
Check these before treating [abc] like a word match.
trap
Set ≠ sequence
[abc] matches one letter. (abc) matches the literal word "abc".
case
Case-sensitive by default
A does not match [abc] unless you add i or list A in the brackets.
length
One character by default
Use + or {n} when you need a run of letters from the set.
negate
[^abc] is the opposite
A leading ^ inside brackets means “not these.” See [^abc].
Compatibility
Browser & Runtime Support
Character classes like [abc] are a core part of JavaScript regular expressions — available in every environment.
✓ Baseline · Widely available
RegExp [abc]
Supported in all browsers and Node.js versions since early ECMAScript. No polyfill needed.
100%Universal support
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
[abc]Universal
Bottom line: Use freely. List only the characters you need; use ranges like [a-z] when the set is large.
Analysis
Performance Notes
Approach
Cost
Best for
/[abc]/
O(n) scan
Detect any set letter
/[abc]+/g
O(n) scan
Extract runs from the set
/^[abc]$/
O(1)–O(n)
Single-letter codes
Small character classes are cheap. Prefer a clear set ([abc]) over listing alternations like a|b|c when matching one character.
Remember
Key Takeaways
Role:[abc] matches one character from a custom set.
Not a word: use (abc) for the literal sequence "abc".
Length: add + or {n} for runs from the set.
Case: default is sensitive — use i or list both cases.
One line:[abc] means “one of these characters” — not the word abc.
Frequently Asked Questions
[abc] is a character class that matches exactly one character — either a, b, or c. Order inside the brackets does not matter: [abc] is the same as [cab].
Not by itself. Each [abc] matches one character. Use [abc]+ for one or more letters from the set, or [abc]{3} for exactly three.
Yes. [abc] matches lowercase a, b, and c only. Include uppercase explicitly ([abcABC]) or use the i flag when that fits your pattern.
[abc] is a character class matching one letter from the set. (abc) is a capturing group matching the literal sequence "abc" in that order.
[abc] matches only three specific letters. [a-z] matches any single lowercase letter from a through z.
Character classes are core regex syntax since early ES. [abc] works in every browser and Node.js version.