How can negative lookahead or negative lookbehind be used in PHP to search for specific patterns within a string?

Negative lookahead or negative lookbehind in PHP can be used to search for specific patterns within a string without including them in the match. This is useful when you want to find a certain pattern but exclude another pattern before or after it. To implement this, you can use the preg_match function with the appropriate regex pattern that includes negative lookahead or negative lookbehind assertions.

$string = "The quick brown fox jumps over the lazy dog";
$pattern = '/\b\w+(?<!quick)\b/'; // Match words that are not preceded by "quick"
if (preg_match($pattern, $string, $matches)) {
    echo "Match found: " . $matches[0];
} else {
    echo "No match found.";
}