如果文本包含某些字符,则正则表达式不匹配

I'm trying to match a string containing certain characters, but not containing others. The problem is that if the string contains an allowed character, the expression finds a match, even though it contains invalid ones (nothing unusual, but not what I want).
The expression I'm using looks like this ([^abc][def])+.
So the question is: Can I define a group of characters, that if contained within the string, will stop the expression from matching the string?

You have to anchor your expression, to make sure no other characters are in the string. For example:

^[chars]+\z

Or you can simply invert the character class and you will get a match if an invalid character is present:

[^chars]

If you want to combine such checks with other expressions in the same regex you could use a lookahead:

^(?=[chars]+\z)expression