4 ms·
E.g. Can you completely parse HTML with regex?
by ethbr1 1y ago
E.g. Can you completely parse HTML with regex?
- astrange 1y agoIf by "parse" you mean "match", the answer is yes because you can express a context-free language in PCRE. If you mean "parse" then it's probably annoying, as all parser generators are, because they're bad at error messages when something has invalid syntax.
- deleted 1y ago[deleted]
- nomel 1y agoIs this true, in practice, given the lenient parsing requirements of the real world?
- joquarky 1y agoTechnically, no Practically, yes
- Cthulhu_ 1y agoYou can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool that is insufficiently sophisticated to understand the constructs employed by HTML. etc. https://stackoverflow.com/a/1732454 https://stackoverflow.com/a/1732454