How does the regex expression handle the presence of multiple slashes in a URL?

When dealing with multiple slashes in a URL, the regex expression should be modified to account for this possibility. One way to handle this is by using the "+" quantifier to match one or more occurrences of the slash character. This ensures that the regex will correctly identify URLs with multiple slashes.

$url = "https://www.example.com//path/to//resource";
$pattern = "/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/";

if (preg_match($pattern, $url)) {
    echo "URL is valid";
} else {
    echo "URL is invalid";
}