I know this question has been asked many times before but none of the options seem to work for me (including the regexes and php's filter_var). I'm looking for a way to make sure a URL is a valid possibility before continuing, below are examples of valid URLs
google.com
www.google.com
http://www.google.com
https://www.google.com
http://google.com
https://google.com
domain-site.com
google.net
google.ca
google.email
IPs (ex. 198.XX.XXX.XXX)
Here are invalid URLs
test
http://test
https://test
Below are links/things I've tried to get the result I want above:
PHP regex for url validation, filter_var is too permisive
filter_var($url_new, FILTER_VALIDATE_URL)
preg_match('#^((https?)://(?:([a-z0-9-.]+:[a-z0-9-.]+)@)?([a-z0-9-.]+)(?::([0-9]+))?)(?:/|$)((?:[^?/]*/)*)([^?]*)(?:\?([^\#]*))?(?:\#.*)?$#i', $toLoad, $tmp)
etc
I know I can cURL to check if a domain exists and this may be the easiest option but its also very slow, I would prefer a regex type solution where I can get a preliminary check of the domain's validity.
Any help is appreciated!