RegEx match open tags except XHTML self-contained tags
stackoverflow.com
external-link
I need to match all of these opening tags: <p> <a href="foo"> But not self-closing tags: <br /> <hr class="foo" /> I came up with this and wanted to make

You know, when I typically ask a question on SO, its because I want to learn how that thing works, or how to write it myself. I usually say as much, but the SO folks are too focused on the ends, they completely neglect the means. Chances are I’m already aware of that no-code solution, but that’s not what I’m asking for.

I think there’s an element of responsibility that some people feel when they respond. If you’re asking for a very niche solution that is likely to create other problems in the future, should anyone else look at your code or refactor it or rely on it, or should you forget how it works, perhaps people are going to be less inclined in helping you craft it.

If you still want to craft it, that’s okay, but you have to expect that some real percent of the answers are going to be those folk who know what the tried and true solution is, often because they’ve lived through the reality that you’re attempting to create and they’ve dealt with the aftermath of doing it special and different.

Which is fine when people do not reject the answers that are different from what they were expecting. Learning that the problem you have is a reason that noone does this, is a valid thing to learn.

It’s usually when I see people moving the goal posts on replies, or complaining that they didn’t answer the exact question that i see as frustrating. Or “I don’t want to do that” with no more info.

But if you are aware of other solutions, you should state that in the question and give your reasons. It’s a waste of time if you know someone might suggest what you have dismissed already.

The html question is a classic for this, they want to find non self closed tags. Why? Why can’t they use a parser? What are they doing with this info? All questions that would give you a good idea on how the problem can be solved. Playing with regex would be a valid answer to that, but is not stated. Unfortunately I find so’s format discourages extra interrogation.

The answer is not an attack on the person, but a frustration at the people before that ignored previous answers to use a parser.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 141 users / day
  • 300 users / week
  • 692 users / month
  • 2.83K users / 6 months
  • 1 subscriber
  • 1.56K Posts
  • 34.7K Comments
  • Modlog