Esta regex encontrará o que você deseja:
^(?=(?:(?!expir).)*$).*(?:error|warning)
Explicação:
^ : begining of line
(?= : start lookahead
(?: : start non capture group
(?!expir) : negative lookahead, make sure w don'thave expir
You may want to add wordboundaries if you don't want to match "expiration"
(?!\bexpir\b)
. : any character but newline
)* : group may appear 0 or moe times
$ : end of line
) : end of lookahead
at this point we are sure we don't have "expir" in the line
so, go to match the wanted words
.* : 0 or more any character but newline
(?: : start non capture group
error : literally error, you could do "\berror\b" if you don't want to match "errors"
| : OR
warning : literally warning, you could do "\bwarning\b" if you don't want to match "warnings"
)
com um arquivo como:
error
warning
abc expir
abc expir warning
abc error expir def
corresponde apenas às linhas 1 e 2.