How to make a preg_match pass when the subject does not contain bad words? This is doing the inverse:
$pattern = '/\b(some|bad|words)\b/i';
function matches($pattern, $value) {
echo "matches $pattern: $value, matches: " . preg_match($pattern, $value)."\n";
}
matches($pattern, "This should match");
matches($pattern, "This bad string should not match");
All examples I found so far do the opposite: they match when subject contains bad words.
I want it to match when it does not contain bad words.
Tried several combinations and searches, but could not find a solution. Using '?!' with '\b' seems to be not possible?