2 ms·
Well, as stated that particuar answer is both right and wrong... Yes, you can not use "true" regular expressions to parse recursive structures. But the librar
by Corazoor 6y ago
Well, as stated that particuar answer is both right and wrong...
Yes, you can not use "true" regular expressions to parse recursive structures.
But the libraries that get used for regular expressions quite often include non-regular extensions (and confusingly call the resulting expressions still "regular").
Most notably, PCRE allows for recursive patterns via "(?R)".
You can absolutely parse arbitrary HTML with it.
In fact you can parse anything whith that, including binary formats. You just can't do it whithout recursively applying the same "regex" again and again...
And precise error handling is basically impossible without writing a proper lexer anyway, since your regex won't (can't, really) tell you where it was thrown off.
It either works or doesn't, the "why" is left to the program to figure out...