Need to write regex for top-level web address which includes letters, numbers, underscores as well as periods, dashes, and a plus sign
Finally I have got this way to cover all above scenarios with below code,
import re
def check_web_address(text):
pattern = r'^[A-Za-z._-][^/@]*$'
result = re.search(pattern, text)
return result != None
print(check_web_address("gmail.com")) # True
print(check_web_address("www@google")) # False
print(check_web_address("www.Coursera.org")) # True
print(check_web_address("web-address.com/homepage")) # False
print(check_web_address("My_Favorite-Blog.US")) # True
This is working fine
pattern = r"^\w.*\.[a-zA-Z]*$"
The pattern that I used to accomplish this was:
pattern = "^[\w]*[\.\-\+][^/@]*$"