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 debug

Matches

  • info
  • user
  • login
  • timeout

Input

all words except WARN here

Matches

  • all
  • words
  • except
  • here

Input

error error error

No 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