A while ago I wrote a blog post about how painful it is to properly parse an email address . This post is kind of like that, except that this time, I take on HTML. I?ve written about parsing HTML with a regular expression in the past and pointed out that it?s extremely tricky and probably not a good idea to use regular expressions in this case. In this post, I want to strip out HTML comments. Why? I had some code that uses a regular expression to strip comments from HTML, but found one of those feared ?pathological? cases in which it seems to never complete and pegs my CPU at 100% in the meanwhile. I figure I might as well look into trying a character by character approach to stripping HTML. It sounds easy at first, and my first attempt was...(read more) ...
Go to the complete details ...