Detect HTML links

  • + 0 comments

    Python 3

    import re
    import sys
    n = int(input())
    html = sys.stdin.read()
    pattern = r'<a\s.*?href="(.*?)".*?>\s*([^<>]*?)</'
    matches = re.findall(pattern, html)
    for match in matches:
        print(match[0], match[1], sep=",")