[^abc] is a negated character class. It matches exactly one character that is nota, b, or c. The ^ must be the first character inside the brackets to mean “not.”
Remember
/[^abc]/ → one char that is NOT a, b, or c
/[abc]/ → one of a, b, or c (the opposite)
/[^abc]+/ → one or more chars outside {a,b,c}
"cab".match(/[^abc]/g) → null
"cat".match(/[^abc]/g) → ["t"]
^ inside [] → negate the class
^ outside [] → start-of-string anchor
Write the class in a regex, then use test, match, or replace.
Write /[^abc]/ (add g to find every match).
Use test() to check if any non-a/b/c character exists.
Use match() to collect characters outside the set.
List more letters after ^ when you need a bigger exclude set.
Piece
Required?
Role
[^abc]
Yes
One character that is not a, b, or c
Quantifier (+, *, …)
Optional
Match a run of allowed (non-excluded) characters
Flag g
Optional
Find / replace all matches
Flag i
Optional
Also treat A, B, C as excluded
Pseudocode
Pseudocode
pattern = [^abc] // "not a, not b, not c"
for each character ch in text:
if ch is NOT in {a, b, c}:
ch matches
else:
ch does not match
// with + : match the longest run of such characters
Reference
Cheat Sheet
Keep these facts handy while writing custom exclude sets.
Topic
Detail
Syntax
/[^abc]/
Meaning
One character that is not a, b, or c
Opposite
[abc]
One or more
/[^abc]+/
Case-insensitive exclude
/[^abc]/i
Bigger set
/[^abcxyz]/ or /[^abc0-9]/
Standard
Core regex (ES3+) — universal support
Try it
Live Preview
Pick a sample string and see every match of /[^abc]/g.
Browser demo of /[^abc]/g — same idea as the examples below.
Result
text = "cat"
text.match(/[^abc]/g)
→ ["t"]
/* a and c skipped; t is outside {a,b,c} */
Code
JavaScript Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Example 1 — Detect Non-a/b/c with test()
Check whether a string contains any character outside {a, b, c}.
Filter:replace(/[^abc]/g, "") keeps only a, b, and c.
Caret:^ inside [] negates; outside it anchors the start.
One line:[^abc] means “not a, b, or c” — the inverse of [abc] for a custom character set.
Frequently Asked Questions
[^abc] is a negated character class. The caret ^ right after [ inverts the set, so the pattern matches any single character that is NOT a, b, or c.
[abc] matches a, b, or c. [^abc] matches everything else—digits, other letters, spaces, and punctuation. They are opposites for those three characters.
No. Every character in "cab" is a, b, or c, so [^abc] finds no match. test() returns false and match() returns null.
Yes, by default. Uppercase A, B, and C are not in the excluded set, so they match [^abc]. Use the i flag if you want to exclude both cases: /[^abc]/i.
Yes. List them after ^: [^abcxyz] excludes six letters. You can mix ranges too: [^abc0-9] excludes a, b, c, and all digits.
No. Outside brackets, ^ means start of string (or line with m). Inside brackets at the start of the class, ^ means “not.”