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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Regex
  3. Applications
  4. Detect the Domain Name
  5. Discussions

Detect the Domain Name

Problem
Submissions
Leaderboard
Discussions

Sort 157 Discussions, By:

recency

Please Login in order to post a comment

  • ricardoandreh
    3 weeks ago+ 0 comments
    import re
    
    is_domain = re.compile(r"https?://(www\.|ww2\.)?(([a-z0-9\-]+\.)+[a-z0-9\-]{2,})")
    
    domains = set([domain[1] for _ in range(int(input())) for domain in is_domain.findall(input())])
    
    print(";".join(sorted(domains)))
    
    0|
    Permalink
  • Taikovic
    4 weeks ago+ 0 comments
    regex_pattern=r'(?:https?://(?:ww.\.)?)([\w\-.]*\.[a-zA-Z]+[^\W\_])'
    
    0|
    Permalink
  • avoscanemile
    2 months ago+ 0 comments

    Python 3

    import sys
    import re
    string = sys.stdin.read()
    matches = re.findall(r'https?:\/\/(?:www\.|ww2\.)?([^\/\.\s]*\.[^\/\\\?_"\'\s]*)', string)
    print(';'.join(sorted(set(matches))))
    
    0|
    Permalink
  • tiagoiesbick
    2 months ago+ 0 comments

    Python 3

    import re
    p = re.compile(r'https?://(w{3}|ww2)?(\.)?([a-z\d\-]+)(\.[a-z\d\-]+)+')
    s = ' '.join([input() for _ in range(int(input()))])
    print(';'.join(sorted(set([i.group().replace('http://', '').replace('https://', '').replace('www.', '').replace('ww2.', '') for i in re.finditer(p, s)]))))
    
    0|
    Permalink
  • Bavly_Zaher
    4 months ago+ 0 comments
    import re
    import sys
    N = int(input())
    S = sys.stdin.read()
    List = sorted(set(re.findall(r'(?<=://)[\w\d-]+[\.]+[\w\.-]+',S)))
    
    for i in range(len(List)):
        List[i] = re.sub("www.","",List[i])
        List[i] = List[i].rstrip("_")
    print(*sorted(set(List)),sep=";")
    
    0|
    Permalink
Load more conversations

Need Help?


View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy