3 ms·
In the case of processing HTML with regex there is a strong theoretical argument against it: a regular expression is a type 3 language while HTML is described b
by titanix2 8y ago
In the case of processing HTML with regex there is a strong theoretical argument against it: a regular expression is a type 3 language while HTML is described by a type 2 grammar. Type 3 being a subset of type 2, regular expressions are not expressives enough to handle the grammar of HTML.
In most cases of best practices however, such a mathematical argument doesn't exist. So, it's more of a battle of (not so) informed technical opinions and experiences, where drawing a clear line is impossible.
Reading list:
https://en.wikipedia.org/wiki/Chomsky_hierarchy https://en.wikipedia.org/wiki/Chomsky_hierarchy
https://stackoverflow.com/a/14207715 https://stackoverflow.com/a/14207715