If comments in XHTML could nest you would have a problem. But this is not the case.
So you need more than a regular expression, hence your premise is incorrect.
The original question is a question about tokenization, not parsing, which is why a regular expression is sufficient.