r/ProgrammerAnimemes • u/bucket3432 • Jun 20 '20
OC Parsing HTML
Enable HLS to view with audio, or disable this notification
1.1k
Upvotes
r/ProgrammerAnimemes • u/bucket3432 • Jun 20 '20
Enable HLS to view with audio, or disable this notification
View all comments
Show parent comment
2
u/Zolhungaj Jun 20 '20
That's because parsing html with regex is a dumb idea.
Sure it could be modified slightly to include self-closing tags, and to capture attributes. But that goes beyond the time worth investing into the idea of parsing html with regex.
And the greedy quantifier is needed if you want a parse-tree, because you'll have to do new passes on each match (because html is not a regular language).