I doubt this is possible by only using a regular expression. There are so many levels of nesting possible, I think you would need a parser instead.
Pritaeas, you are right,it is possible by regular expression,I found the solution in php way it uses preg_match_all but i'm in need of alternative for it in java script.which should validate ,, tags that are closed properly or not.
Thanks:-/
Javescript RegExp will do _precisely_ what preg_match does.
Neither will solve the general problem, and even the three cases you have now given will not be easy.
Part of the difficulty is that "closed properly" != "closed".