How can Negative Lookbehind and Negative Lookahead assertions be used in PHP regex?

Negative Lookbehind and Negative Lookahead assertions can be used in PHP regex to match patterns that are not preceded or followed by certain characters or patterns. This can be useful when you want to exclude specific cases from your regex matches. To use Negative Lookbehind, you can use the syntax `(?<!...)`, and for Negative Lookahead, you can use `(?!...)`. Example PHP code snippet:

```php
$string = &quot;apple orange banana pear&quot;;
$pattern = &quot;/\b(?!orange\b)\w+\b/&quot;;
preg_match_all($pattern, $string, $matches);
print_r($matches[0]);
```

In this code snippet, the regex pattern `/\b(?!orange\b)\w+\b/` will match words that are not &quot;orange&quot; in the given string. The Negative Lookahead `(?!)` is used to ensure that the word &quot;orange&quot; is not followed by a word boundary `\b`.