I am using python and would like a simple regex to check for a domain name's validity. I check at least write domain name.
url = 'https://stackoverflow'
keyword = 'foo'
with self.assertRaises(ValueError):
check_keyword(url, keyword)
I try unit testing on url textfield and there is main.py page where I done the validation main.py-
def check_keyword(url, keyword):
if re.match("^(((([A-Za-z0-9]+){1,63}\.)|(([A-Za-z0-9]+(\-)+[A-Za-z0-9]+){1,63}\.))+){1,255}$" ,url):
return ValueError("Invalid")
Example
www.google (Invalid)
https://stackoverflow (Invalid)