Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

I posted this answer to a question where someone was trying to use regex to parse Html. The question was "How can I get my regex to work?" and my answer was "Don't use regex, use this instead".

Should I have posted my answer as a comment?

share|improve this question
I originally converted your answer to a comment, but thought better of it; since it has three upvotes on it and four comments posted below it, it's now better off as an answer. – Robert Harvey Aug 10 '11 at 15:03
I hate this "burn the witch" attitude on SO when it comes to parsing HTML with regex. – NullUserException อ_อ Sep 28 '11 at 21:35
@NullUserException My answer is about giving an easier way to solve the guys problem. I didn't link to "the answer" - you have assumed that I'm trying to "burn witches" just because I'm suggesting that regex isn't the best way of parsing html. Are you claiming that we shouldn't tell people this any more now that "the answer" has gotten old? – Justin Sep 29 '11 at 17:32
up vote 19 down vote accepted

IMO, no. You can sometimes best help a user by solving the problem they're trying to solve (parsing HTML) rather than the problem they think they're trying to solve (parsing HTML with regex). Some users get self-righteous about it and downvote your answer, but you're not the asker's slave; you don't need to bow to their every whim, especially if there doesn't seem to be a good reason for needing to use a particular tool or method.

Post what you think is best for the problem at hand. I've found I get rewarded for it more often than I am punished. Just don't come across arrogant, of course! No "That's dumb" or anything :P

share|improve this answer
Agreed. If other people think that your solution is better than the one they propose, the voting system will handle it. And the person asking the question may appreciate an answer that is technically out of scope. If they don't, they'll say so. Furthermore, you can help others by pointing out a better alternative. – Nicol Bolas Sep 29 '11 at 9:35
I disagree. I have asked questions that seem to assume poor answers to the problem. However, this is often because I strip out a lot of context, that is unnecessary for the direct answer. If I include that context-specific material, I need to write a thesis to explain myself (and I have so that some answerers would stop complaining and actually give me a valid answer.) I'm usually correct in needing an answer for the questions I ask. However, I don't want to write a short essay to setup a question I can ask in two or three rather short sentences. – RLH May 25 '12 at 18:30
@RLH I suspect you're overstating the case, but a simple "I need to use X for reasons I won't go into" should suffice. I'm not advocating ignoring the question, I'm advocating solving the user's problem. – Matthew Read May 26 '12 at 4:49

Yes, you should have posted your comment as a comment.

Better would be to answering how to solve this the way as the OP asked whenever possible and then at the bottom of the answer subtly remark it as an unrelated note that there are much better alternatives to the solution the OP is trying to use and elaborate it as well.

If it's not possible or not easily possible at all, then you should elaborate that part in detail as well. Just saying "Don't use solution X, you should use solution Y" without further elaboration is IMO not an answer, but more a comment. In your case, try to explain in detail why parsing HTML with regex is an insane solution. Although your answer is understood by the community, it might not be understood by the OP.

share|improve this answer

Both yes and no answers have already been given to this question; the only thing left to say is, it depends.

It can be either extremely helpful or extremely frustrating to be told, "Don't do it like that; do it like this." It can be liberating to know that there is not only a better clunky way, but a smooth, powerful, easy way. However, sometimes a user is already aware of the better way of doing things, but doesn't have that as a possibility.

For example, where I work, I am not able to install software on my computer; indeed, the computer where I do most of my work is not even connected to the internet. Thus, when I ask Vim questions, for example, answers that tell me to just download and install some plugin are helpful if I ever run into the same issue at home, but don't help me at all at work. I really just do want the quick 'n' dirty solution at work because I don't have another option.

So my advice is, make sure the user is aware of the better way of doing it, but be careful with how you phrase it. This:

If you have the option, doing it like [alternative solution] would be must better than the approach you are heading towards, because of [well-explained reasons]. If there is something that is prohibitive about the better solution in your case, tho, you can do what you are trying to like [explanation].

is a much, much better answer than:

Don't use X. Use Y instead.

I just read Chichiray's answer more carefully and realized that says some very similar things, even though he began by saying "no". I didn't plagiarize, I promise.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .