6 ms·
I've seen many people complain about StackOverflow, but this is the best example I've ever encountered. The question: How to match <p> <a href="foo"> The
by imedadel 6y ago
I've seen many people complain about StackOverflow, but this is the best example I've ever encountered.
The question: How to match
<p>
<a href="foo">
The answers: rants about how RegEx is not suitable for parsing entire HTML.
Only the 5th answer starts to actually answer the question.
- chrismorgan 6y ago“You’re asking the wrong question” is a valid response.
- tomashubelbauer 6y agoYes, but I wish people who like to assume and answer saying so would still answer the question they think is wrong. Context matters and I don't think you can determine that with certainly nearly as often as some people online like to think.
- shawnz 6y agoIn this case the answer is correct given the parameters of the question: There is no way to have a regex that only matches the things which OP wants to match, but not any of the things OP doesn't want to match. Given a specific situation, like a particular page or something, sure, regexes are still a possibility for solving the problem. The 2nd highest answer on the page details exactly that. So what is the problem? Is every single contributer obligated to artificially entertain the OP's preconceptions before giving the advice which they believe actually helps best? For example, if I were knowledgeable about XML but not regex, should I just not contribute in such a situation?
- dgellow 6y agoReally, it depends the context. You might be aware that’s not something to generally do and still want to know the answer to the actual question.
- anon946 6y agoIf the question were about full validated parsing of HTML with a regex, then I'd agree that "You can't do that" might be part of a valid answer. But finding tags is not doing a full validating parse. Note that the set of valid C programs is not a context-free language. Yet it's common to use a context free-based approach to parsing. You just add additional code to handle the context-sensitive aspects (such as a symbol table).
- bill_mon 6y agoI disagree, I see it as saying "you don't know what you really want, but I can read your mind". It's disrespectful and not giving the benefit of the doubt.
- ivanbakel 6y ago>It's disrespectful and not giving the benefit of the doubt. Unfortunately, a good number of users who post questions on StackOverflow have not earned the benefit of the doubt. Browsing the site, you will occasionally come across questions which are the tech equivalent of asking "Which screwdriver is the right size to stick in this electrical socket?" Frame challenges are a necessary part of learning, so they belong on a Q&A site. If a user doesn't want their problem to be challenged, the onus is on them to clarify in the question why their particular approach is the necessary one. It's only possible to respond with alternative solutions when the problem is not specified enough.
- jstanley 6y ago> Which screwdriver is the right size to stick in this electrical socket? Note that this is a legitimate technique in UK sockets. The live and neutral pins have a little gate over them that is retracted when you insert the earth pin, so you need to first stick a screwdriver into the earth pin in order to get your fingers into the live pin.
- jerven 6y agoI can't parse if this is humour or a mistake. Putting your fingers on the live pin is not a great idea, trying this to get an euro 15 plug into an UK socket, also not great but in a different category.
- Keyframe 6y agoWell, there's also a mains tester screwdriver which is a legit tool that you stick into a socket and also participate in the electrict current loop for the light on it to light up.
- anoncake 6y agoBut not a valid answer. That's what comments are for.
- andybak 6y agohttps://en.wikipedia.org/wiki/XY_problem https://en.wikipedia.org/wiki/XY_problem https://xyproblem.info/ https://xyproblem.info/ https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem https://meta.stackexchange.com/questions/66377/what-is-the-x...
- josefx 6y agoDo you educate people about the complexity of the physics and bureaucracy involved with defining the current time every time someone asks you "what time is it?" Or do avoid going onto irrelevant tangents that get you labeled as crazy and just tell them the current time?
- IgorPartola 6y agoWhat time is it isn’t an invalid question. “How do I make my hamster grow wings and fly?” is. How to parse HTML with a RegEx is an in-between. For a specialized case, why not? Answer that question, then provide a counter example to show how it will be very fragile, then explain the theory, then show a better way. IME that tends to work better to teach someone what you think they should know.
- jasode 6y ago>Do you educate people about the complexity of the physics and bureaucracy involved with defining the current time every time someone asks you "what time is it?" Maybe you're (inadvertently) making a caricature by using a simple "what time is it?" question but many user questions are under-specified. Because of that, Stackoverflow answerers in particular do go into the extra complexities because it's part of its editorial DNA to restate the q&a so it's a high-quality community knowledgebase instead of just answering the direct question as stated. I tried to explain this hard-to-grasp nuance previously: https://news.ycombinator.com/item?id=21115438 https://news.ycombinator.com/item?id=21115438 But sometimes, this X-Y problem editorializing mechanism gets so enthusiastic that it can detract from a correct answer. Here's a famous example of a string bytes extraction question with smart people arguing with the correct answers from user541686 (was Mehrdad) and Michael Buen: + correct answer has lots of X-Y pushback in the comments: https://stackoverflow.com/questions/472906/how-do-i-get-a-consistent-byte-representation-of-strings-in-c-sharp-without-manu/10380166#10380166 https://stackoverflow.com/questions/472906/how-do-i-get-a-co... + another correct answer from Buen that emphasizes user541686/Mehrdad works for broken unpaired surrogates: https://stackoverflow.com/questions/472906/how-do-i-get-a-consistent-byte-representation-of-strings-in-c-sharp-without-manu/10384024#10384024 https://stackoverflow.com/questions/472906/how-do-i-get-a-co... The meta layer issue is that the question is underspecified which causes 2 sides with very intelligent people arguing whether or not it's an X-Y problem!
- mumblemumble 6y agoOnly when you know enough about the person's context to be able to tell them what question they should be asking instead. If you don't have that context, then the correct thing to do is to ask for more information, or say, "did you consider this", or find some other way to come up with a constructive response. You don't just assume you know what the person really wants to do and then try to mainsplain it to them.
- armada651 6y agoActually, if you read his rant all the way to the end he does offer a helpful suggestion: > Have you tried using an XML parser instead?
- andybak 6y agoExcept he's wrong in this case. The OP could use a regex in this specific scenario.
- chrismorgan 6y agoNot true. The questioner has not provided anywhere near enough detail to determine if regular expressions are sufficient. For example: should <br> match, or not? Its semantics are identical to <br />. To determine if regular expressions are enough, you would need to know exactly what markup you’re dealing with, and that has not been provided.
- andybak 6y agoYeah. I guess in other parts of this discussion I'm arguing for always probing hidden assumptions and missing background whilst here I'm saying "let's interpret the question in the most charitable way possible". Plus - Stack Overflow is about trying to generalize any given question to maximize it's wider usefulness.
- bhaak 6y ago> Plus - Stack Overflow is about trying to generalize any given question to maximize it's wider usefulness. Since when? You don't get extra points if you write stuff that doesn't concern OP's problem. Most SO problems don't get viral and get lots of upvotes from other people. From a game theory perspective, it doesn't make sense to add more to an answer than to make it the accepted one. If you have slightly different constraints you are encouraged to open another question. Discussions are frowned upon and sometimes even interrupted by admins so you can't discuss if your situation is different from OP's situation and so could warrant a different answer.
- ajanuary 6y agoAccording to the post, the more important part of the question is "what do you think", to which "I think you shouldn't, because..." is a good answer.
- EamonnMR 6y agoI find this type of answer infinitely more paletable than "your question is answered here" or "comments are not for extended discussion, this conversation has been moved to chat"
- omginternets 6y agoIn all fairness, he does provide hints as to why regex will not work (namely: HTML is not a regular grammar). Sure, it's somewhat obscured by the humorous rant, but it's not that bad an answer, either. More to the point: I'm not sure I want to suck the humor out of everything. I agree that SO has problems, but humor and poetry are worthwhile things in otherewise serious places. It's all about quantity.
- seiferteric 6y agoYes, I have been down-voted and scolded for answering a question as literally described simply because others would rather assume the ignorance of the questioner. Yes I know people will often ask a question due to not understanding what they are doing, but when 10 other people have already responded with "don't do it that way!" I think it can be useful to actually answer the question as stated (if possible).
- commandlinefan 6y agohttps://www.aprogrammerlife.com/top-rated/stack-overflow-how-long-to-hardboil-an-egg-389 https://www.aprogrammerlife.com/top-rated/stack-overflow-how...