import re
def checkUrlValidity(str):
regex = ("((http|https)://)(www.)?" +
"[a-zA-Z0-9@:%._\\+~#?&//=]" +
"{2,256}\\.[a-z]" +
"{2,6}\\b([-a-zA-Z0-9@:%" +
"._\\+~#?&//=]*)")
x = re.compile(regex)
if (str == None):
return False
if(re.search(x, str)):
return True
else:
return False
url = "https://www.test.com"
if(checkUrlValidity(url) == True):
print("matches on the screen")
else:
print("No web addresses found")
Comments
Leave a comment