We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Detect the Domain Name
Detect the Domain Name
Sort by
recency
|
167 Discussions
|
Please Login in order to post a comment
Detecting a domain name typically involves parsing the URL string to extract the domain using regex or built-in libraries in languages like Python or JavaScript. According to Wikipedia, a domain name identifies a realm of administrative autonomy within the Internet. In coding challenges, tools like urlparse or regex can simplify this process efficiently. I was practicing with real-world data like food service websites—checking out the Dairy queen menu helped simulate parsing dynamic URLs. It’s a fun way to blend real examples into coding logic while sharpening string manipulation skills.
import re import sys
html= sys.stdin.read()
pattern= r'https?://(?:www.|ww2.)?([a-zA-Z0-9-]+.?[a-zA-Z0-9-]+.[a-zA-Z].?[a-zA-Z])'
matches=re.findall(pattern,html)
output=sorted(set(url for url in matches))
print(';'.join(output))
I think there is a problem with the expected output of Test case 1. If you inspect the inputs (html). You can see these lines:
however, those 2 urls does not appear in the expected output