3 ms·
In general, no. Regular expressions match regular languages but HTML is a context-free language. Every regular grammar is context-free but not all context-free
by giardini 14y ago
In general, no. Regular expressions match regular languages but HTML is a context-free language. Every regular grammar is context-free but not all context-free grammars are regular.
See
http://stackoverflow.com/questions/590747/using-regular-expressions-to-parse-html-why-not http://stackoverflow.com/questions/590747/using-regular-expr... for details. Also
http://stackoverflow.com/questions/5175840/is-html-a-context-free-language http://stackoverflow.com/questions/5175840/is-html-a-context...
And then you have attempts to recover when HTML is ill-formed: http://en.wikipedia.org/wiki/Tag_soup http://en.wikipedia.org/wiki/Tag_soup
- omaranto 14y agoIs your comment aimed at people who didn't read the linked article?