Detect HTML Tags

  • + 0 comments

    For Python 3:

    import re
    tag_pattern = re.compile(r'<\s*(?!/|!)([A-Za-z][\w\-]*)',re.ASCII)
    
    number_of_lines = int(input())
    unique_tag_names = set()
    for _ in range(number_of_lines):
        html_line = input()
        unique_tag_names.update(tag_pattern.findall(html_line))
        
    print(";".join(sorted(unique_tag_names)))