
Given a string representing a code snippet, implement a tag validator to parse the leetcode and return whether it is valid.
A code snippet is valid if all the following rules hold:
The code must wrapped in a valid closed tag. Otherwise, the code is invalid.
A closed tag has exactly the following format : TAG_CONTENT. Among them is the start tag, and is the end tag.
The TAG_NAME in start and end tags should the same. A closed tag is valid if and only if the TAG_NAME and TAG_CONTENT are valid.
A valid TAG_NAME only contain upper-case letters, and has length in range [1,9]. Otherwise, the TAG_NAME is invalid.

A valid TAG_CONTENT may contain other valid closed tags, cdata and any characters EXCEPT unmatched <, unmatched start and end tag, and unmatched and closed tags with invalid TAG_NAME.
Otherwise, the TAG_CONTENT is invalid. A start tag is unmatched if no end tag exists with the same TAG_NAME, and vice versa.
However, you also need to consider the issue of unbalanced when tags are nested.
A < is unmatched if you cannot find a subsequent >. And when you find a < and should be parsed as TAG_NAME (not necessarily valid).
The cdata has the following format . The range of CDATA_CONTENT is defined as the characters between .
Also read : How to Document preparation services.
CDATA_CONTENT may contain any characters.
The function of cdata is to forbid the validator to parse CDATA_CONTENT so even it has some characters that can parsed as tag you should treat it as regular characters.
Given a string s containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid.
An input string is valid if leetcode:
- Open brackets must be closed by the same type of brackets.
- Open brackets must be closed in the correct order.
- Every close bracket has a corresponding open bracket of the same type.