Detect HTML Tags – HackerRank Solution

In this post, we will solve Detect HTML Tags HackerRank Solution. This problem (Detect HTML Tags) is a part of HackerRank Regex series.

Solution – Detect HTML Tags – HackerRank Solution

Python

import re
pattern = re.compile('<\\s*([a-zA-Z0-9]*)\\s*>?')
n = int(input())
tag_list = list()
for i in range(n):
    x = str(input())
    y = re.findall(pattern, x)
    for z in y:
        if(len(z) != 0 and z not in tag_list):
            tag_list.append(z)
tag_list.sort()
for i in range(len(tag_list)):
    if(i == len(tag_list) - 1):
        print(tag_list[i])
    else:
        print(tag_list[i],end=";")

Note: This problem (Detect HTML Tags) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.

Leave a Comment

Your email address will not be published. Required fields are marked *