Text Processingflags: gi
Negative Lookahead
Use negative lookahead `(?!...)` to match words that are NOT in a blocklist (here: log-level keywords).
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\b(?!error|warn|debug)[a-z]+\b (flags: gi)Raw source: \b(?!error|warn|debug)[a-z]+\b
How it works
\b is a word boundary. (?!error|warn|debug) is a zero-width assertion that fails if the upcoming text is one of the blocked words. [a-z]+ then matches an actual word. The result: every word EXCEPT error/warn/debug. Lookarounds work in JS and Python; Go's RE2 does NOT support them.
Examples
Input
info user login error timeout debugMatches
infouserlogintimeout
Input
all words except WARN hereMatches
allwordsexcepthere
Input
error error errorNo match
—Common use cases
- •Excluding reserved keywords from a token scan
- •Filename validation that rejects forbidden names
- •Log filtering — keep everything except known noise
- •Compound rules in linters
Related patterns
Negative Lookbehind (Decimals Without $)
Text ProcessingUse negative lookbehind `(?<!...)` to match decimal numbers NOT preceded by a dollar sign.
Positive Lookahead (Password)
Text ProcessingUse positive lookahead `(?=...)` to require the password contain at least one digit and one uppercase letter.
Duplicate Word
Text ProcessingDetects consecutive duplicate words using a backreference.
Non-Capturing Group (Image URL)
Text ProcessingUse non-capturing groups `(?:...)` to alternate without polluting the captured-groups list.