Hey. I would like to check these following URLs, so all of them will go with or without the http / www part in them while the TLD is present, e.g. .com, .net, .org, etc.
Valid URLs must be:
http://www.domain.com http://domain.com https://www.domain.com https://domain.com www.domain.com domain.com
To support long tlds:
http://www.domain.com.uk http://domain.com.uk https://www.domain.com.uk https://domain.com.uk www.domain.com.uk domain.com.uk
To support dashes (-):
http://www.domain-here.com http://domain-here.com https://www.domain-here.com https://domain-here.com www.domain-here.com domain-here.com
Also to support domain numbers:
http://www.domain1-test-here.com http://domain1-test-here.com https://www.domain1-test-here.com https://domain1-test-here.com www.domain1-test-here.com domain-here.com
It is also possible to allow even IP addresses:
127.127.127.127
(but this is optional!)
Also allow dash (-), forget that =)
I found many functions that test one or the other, but not both at the same time. If someone knows a good regex for this, please share. Thank you for your help.
source share