What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 122 Stack Exchange communities.

I love the famous answer by bobince regarding using regex for html (and other markup) tags.

It is probably one of the most-linked questions answers on SO.

However, seeing it linked to in this question got me thinking. Is it linked so often because people asking related questions are not finding it because the title is a little too specific? ("RegEx match open tags except XHTML self-contained tags")?

If the title were "Using RegEx to match HTML tags" or even "Using RegEx to match tags" would people be more likely to come across it? I have a suspicion that "XHTML," "Open Tags," and "Self-contained" are keywords that might cause people to think it doesn't apply to their case.


share|improve this question
Just for the record, though I guess you know: it is explicitly linked, not just listed in the "related" list. –  Arjan Jan 13 '11 at 18:00
add comment

3 Answers

up vote 11 down vote accepted

No. Changing the title to something misrepresentative would only lead to more unhelpful links in unrelated questions.

Bobinces fun answer gets glorifyed on SO, but it is not very useful in itself. Notice how the question there was about parsing nested XHTML. There are many good technical answers on that page. The bobince answer isn't.

When peole ask about "parsing" HTML, they mostly mean "extracting". And your linked example specifically does. If so, linking to bobinces answer is the most dissocial thing you could do. Because it doesn't apply. Regular expressions are very much sufficient to extract the contents of a single tag.

Changing the title of the question to suit the nonanswer would make it easier to find, yes. But it's doubtful that this helps newbies - who don't search anyway. But it is highly likely that this would lead to more insolent links on only vaguely related questions.

Anyway, there was another discussion about this two weeks ago: Regex and HTML - The long tail annoys me

share|improve this answer
I'm so happy that you mentions this. Regex works great for parsing data out of given tags. But if you even mention regex and html in the same sentence people's heads explode. –  jjnguy Jan 14 '11 at 15:16
+1 because this is a very well thought-out answer and perfectly applicable. Also, because you mention that using a regex is perfectly acceptable for extracting the content of a single tag. –  JYelton Jan 14 '11 at 18:08
@JYelton: for the record: I do actually agree with your sentiment that every SO user should see the bobince answer once in their life. However it's meanwhile beyond meme status, and too often used as cargo cult programming advise. But of course better reference questions are also difficult to find. –  mario Jan 14 '11 at 18:13
add comment

While I agree that the title should be changed if you want to receive better search hits on the answer, I don't think that the answer is a very good one to help out people looking to parse HTML.

Its message has become obscured in the fame and theatrics of the answer. I think there are better answers out there to the question "How can I parse HTML with Regex?"

share|improve this answer
Aye, there's a lot of thought that as truthful and memetic as the answer is, to people who aren't "in" it's just unhelpful. It may start off with the literal "You can't", which is what makes it still an answer, but it's very likely that inexperienced users will just be put off by its length. –  Grace Note Jan 13 '11 at 17:49
I agree, the "famous answer" isn't actually that helpful to a new user, while the more experienced community finds it humorous. That said, there are other answers and comments on that thread that might get a new user on the right track. –  JYelton Jan 13 '11 at 17:52
@jye, I think that answer is far to distracting. –  jjnguy Jan 13 '11 at 18:02
Y'all are stuffy elitists. I learned everything I know about parsing HTML with regex from reading that answer. Also, Ph'nglui mglw'nafh Tony R'lyeh wgah'nagl fhtagn. –  Shog9 Jan 14 '11 at 3:16
@Shog, I disagree - O͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝ –  jjnguy Jan 14 '11 at 4:59
The accepted answer with 4k upvotes that starts "You can't parse [X]HTML with regex." is perfectly clear, the rest of the post demonstrates that "that way madness lies". I was a dev with half a year's experience when I first read it linked from a Coding Horror blog and I fully understood its message. –  StuperUser Jan 14 '11 at 9:42
@Stuper, I'm not arguing that it can't be helpful. I'm just arguing that there are much better ways to present that information. –  jjnguy Jan 14 '11 at 14:46
That's very true. –  StuperUser Jan 14 '11 at 15:12
add comment

I'd rather it be kept as-is so that it's more authentic.

share|improve this answer
add comment

You must log in to answer this question.

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