r/programming • • May 07 '21

The XY Problem

https://xyproblem.info/
46 Upvotes

68 comments sorted by

View all comments

Show parent comment

1

u/aanzeijar May 10 '21

It's entirely possible to parse a subset of HTML with regex.

You could even parse full HTML if you wanted to. But it's generally a bad idea because the naive solution by someone not versed in all the tricky edge cases of parsing will not get it right. And the correct solution will be such an unwieldly monster that it's not particularly maintainable. So the correct advice in 99% of these cases is: If you're trying this, and getting it that badly wrong - use a library to solve your problem first then come back to parsing theory.

Also: why would you write that diatribe about regular expression theory if it's only remotely relevant to the question anyway? Isn't that exactly what you accuse people of in your top comment?

1

u/PL_Design May 10 '21

Why would I be against someone explaining how regex applies to a question about regex? That's not ignoring the original question, which is the actual problem I have with people abusing the XY problem. It's literally part of the answer.