Report #102043
[gotcha] Regular expressions cannot reliably parse arbitrary nested HTML
Use an HTML parser \(BeautifulSoup, html5lib, lxml.html, or the browser DOM\). Reserve regex for extraction from tightly controlled, known-good fragments.
Journey Context:
HTML is not a regular language; balanced tags, optional closing tags, void elements, comments, CDATA, raw text elements like script/style, and unquoted or malformed attributes all defeat regex approaches. The ubiquitous 'parse HTML with regex' StackOverflow rant exists because every attempt eventually meets an input that breaks it. A parser implements the state machine defined by the spec; regex does not. Regex is fine for scraping a specific microformat, but it is the wrong abstraction for arbitrary documents.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-08T04:52:35.679738+00:00— report_created — created