Why you shouldn't parse HTML with regexp


On StackOverflow, Robert Harvey — apparently a man who's been around the block a few times — has some impassioned advice for naive developers who are contemplating parsing HTML using regular expressions:

HTML is a language of sufficient complexity that it cannot be parsed by regular expressions. Even Jon Skeet cannot parse HTML using regular expressions. Every time you attempt to parse HTML with regular expressions, the unholy child weeps the blood of virgins, and Russian hackers pwn your webapp. Parsing HTML with regex summons tainted souls into the realm of the living. HTML and regex go together like love, marriage, and ritual infanticide. The <center> cannot hold it is too late. The force of regex and HTML together in the same conceptual space will destroy your mind like so much watery putty. If you parse HTML with regex you are giving in to Them and their blasphemous ways which doom us all to inhuman toil for the One whose Name cannot be expressed in the Basic Multilingual Plane, he comes. HTML-plus-regexp will liquify the n​erves of the sentient whilst you observe, your psyche withering in the onslaught of horror.

Don't Parse HTML with Regexp

(Thanks, Fipi Lele!)

(Image: RANT, this way, a Creative Commons Attribution Share-Alike (2.0) image from nesster's photostream)