Use it in a cURL request and see if you get a valid HTTP response code.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
I have limited skills with regular expressions, but the one you're using looks like it might have been designed for a specific situation. So it might not be suitable as a general URL validator. If you search for a new regular expression to use, because ICANN is approving so many new Top Level Domain (TLD) names, I'd suggest that you look for one that does NOT check for specific TLDs like .com or .net or TLDs of a specific length - '{2,3}'. If you're not sure, do some testing with a .info or a .name domain and see what happens.
thanks guys, though not sure what you meant Nog dog
It would be similar to a user registration page "testing" your email address by sending you a confirmation email to that address with some link you need to click in order to complete the process.
In this case, you could use cURL (or some other technique to send a HTTP request) using the supplied URL, and if it results in a successful response, then by definition it is a valid URL, both in terms of syntax and actually pointing to a valid web resource.
If you are, for some reason, only concerned with syntax, then you would need to be very meticulous with any regular expression syntax in order to avoid false negatives against valid URLs which happen to break imagined "rules". This means going through the relevant specifications and ensuring you understand exactly what is and is not legal for the structure of a URL.
(The same holds true for many email address syntax regexp's you may find out there, most of which have the potential to provide false negatives.)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks