How can assertions in PHP regex be used to filter specific text patterns in URLs?

To filter specific text patterns in URLs using assertions in PHP regex, you can use positive or negative lookahead assertions to match patterns that occur before or after a certain point in the URL. This allows you to target specific text patterns within the URL without capturing the entire string.

$url = "https://www.example.com/page123";
$pattern = "/(?<=https:\/\/www\.example\.com\/)page\d+/"; // Positive Lookbehind Assertion
preg_match($pattern, $url, $matches);
echo $matches[0]; // Output: page123