in reply to regex and HTML

If it's well-formed, XHTML-wise, try XML::Parser.