What are the potential pitfalls of using regular expressions in PHP for matching URLs?
One potential pitfall of using regular expressions in PHP for matching URLs is that they can be complex and difficult to maintain. To solve this issue, you can use the built-in `filter_var()` function in PHP with the `FILTER_VALIDATE_URL` filter option. This function provides a simpler and more reliable way to validate URLs in PHP.
$url = "https://www.example.com";
if (filter_var($url, FILTER_VALIDATE_URL)) {
echo "Valid URL";
} else {
echo "Invalid URL";
}