> and dozens of people post answers claiming that this is the wrong way to do it and that they should use some other tech to solve the problem
Yes, and they are factually correct in doing so. The correct answer to the question: "How do I use a hammer to tighten a screw" isn't a lengthy description of how to perform some magic with a hammer. The correct answer is: "You don't. Use a screwdriver."
HTML isn't parseable with regex. The various answers under the question explain in great detail why [1] that is the case.
SO isn't a help forum, it's a question archive. The purpose of an answer isn't to solve one guys specific question, but to provide an answer that is useful to all people who ever stumble upon this question.
Your response and the other responses are proving our point. It wasn't about context free grammars, level 2 or level 3, etc. It was a very limited subset of a problem. Answer should have been, "while I don't recommend doing it the way you want to do it, that should work for your limited subset".
Yes, and answers on that very page, with lots of upvotes, do exactly that. People looking for answers online, can reasonably be expected to scroll down a page with results.
Poster is not asking for this. He is asking how to parse a specific subset of HTML. And it is demonstrably parseable.
> The correct answer to the question: "How do I use a hammer to tighten a screw" isn't a lengthy description of how to perform some magic with a hammer. The correct answer is: "You don't. Use a screwdriver."
It is not the appropriate way to tighten a screw, but there likely is a correct way to do it with a hammer.
It is fine to point out that there are better ways to parse that HTML, but it is not wrong to do it with regexes.
Sorry to be blunt, but having coworkers like you make the job really annoying. I'm not a newbie, but a seasoned programmer. If I'm asking a question and am in a domain with a fair amount of experience, don't give me patronizing answers.
Poster is not the one answers are for. Answers are for everyone who stumbles upon this question in the future, and the general topic of the question is very much about parsing some HTML with regex.
Again: SO != Help FOrum
> but there likely is a correct way to do it with a hammer.
No, there isn't. Because the correct way is to use a screwdriver. There is certainly a way to do it with a hammer, same as there is a way to write a webserver in brainf__k. Doesn't mean that way is good or should be done.
> Sorry to be blunt, but having coworkers like you make the job really annoying.
Bluntness is fine. I will be blunt as well: Having to fix code full of hammers used to tighten screws is a lot more annoying than having colleagues who try to prevent a codebase full of hammers in the first place.
> The correct answer to the question: "How do I use a hammer to tighten a screw" isn't a lengthy description of how to perform some magic with a hammer. The correct answer is: "You don't. Use a screwdriver."
My car broke down in the middle of the desert because of a screw that came loose and all I have is a hammer. You have just condemned me to death because you assume you know better.
Nothing on that questions makes me think the person asking it wants to parse HTML. Most HTML parsers will never give the result the question described. And unless you want to dig into tar structure, solving that question is an essential part of creating a parser.
Yes, and they are factually correct in doing so. The correct answer to the question: "How do I use a hammer to tighten a screw" isn't a lengthy description of how to perform some magic with a hammer. The correct answer is: "You don't. Use a screwdriver."
HTML isn't parseable with regex. The various answers under the question explain in great detail why [1] that is the case.
SO isn't a help forum, it's a question archive. The purpose of an answer isn't to solve one guys specific question, but to provide an answer that is useful to all people who ever stumble upon this question.
[1]: https://stackoverflow.com/a/1758162/19508364