97 points

no, this is one of the worst answers on Stack Overflow

OP had a specific question to capture opening tags. The thing OP asked about can be done with regular expressions. It is true that arbitrarily nested languages like HTML cannot generally be parsed with regular expressions, but that is not what OP asked about.

permalink
report
reply
86 points

This is StackOverflow after all. Your question is wrong. Your problem is wrong. You are wrong. I am right. Thread locked. Go read this other post that is totally unrelated to your problem I’ve decided isn’t the problem you’re facing because. I. Am. Right.

permalink
report
parent
reply
17 points

That’s why LLMs are so infuriatingly stubborn, they’re trained on these keyboard warriors

permalink
report
parent
reply
15 points
*

Could be worse. At least it’s not Microsoft’s support forums:

Hey, I see you’re having problems with <copy-paste key words from OP>. Try the following and see if it fixes your issue.

Open a command prompt and enter ”sfc /scannow".

I hope this helps!

(Reply marked as solution, thread closed.)

permalink
report
parent
reply
4 points
*

I have X years experience with {keyword salad}.

Can you confirm {details already in the opening post}?

permalink
report
parent
reply
4 points

answers.mirosoft.com is the worst. learn.microsoft.com can be decent at times though

permalink
report
parent
reply
3 points

I had a decade old question marked as a duplicate and downvoted three times after years no no activity. SE is such a joke nowadays.

permalink
report
parent
reply
7 points

It can’t be done, as an opening tag in html can contain anything in its attributes, even JavaScript (e.g. onclick handler).

permalink
report
parent
reply
-1 points

??? Non sequitur

permalink
report
parent
reply
5 points

You can’t parse every html opening tag with regex, because a html opening tag doesn’t have a set structure. How would you match, with regex, this opening tag? <mytag myattribute="<value of \"myattribute\">" >

permalink
report
parent
reply
0 points

It can be done with simple regex of the kind proposed in various answers there iff the html is known to be limited to the subset of html where that sort of thing can easily be made to work. The question does not tell us whether or not that is the case, so everyone is free to make their own assumptions and argue as if they know what’s going on.

permalink
report
parent
reply
84 points

SO in a nutshell:

“I need to do X”

“Have you tried Y?”

“No, because I don’t need Y, I need X.”

“Well you can do Z if you can’t do Y.”

“OK, sure. But how do I do X?”

“Why do you need to do X?”

(Explains why in my hyper-specific situation, I need to do X, and Y and Z won’t work)

This question has been marked as a duplicate of “How to do Y”

permalink
report
reply
12 points

Except in 99% of cases the person is asking an xy problem, and if they ever explained the why, they would get a proper answer.

Often the reason no one does the hyper-specific thing, is that there are better non code solutions, it’s massively insecure, or is just stupid micromanaging.

permalink
report
parent
reply
8 points

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.

permalink
report
parent
reply
4 points

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.

permalink
report
parent
reply
1 point

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.

permalink
report
parent
reply
5 points
*

and if they ever explained the why, they would get a proper answer.

That’s funny, every time I’ve explained in detail why my question isn’t a duplicate nobody fucking cares and it still gets closed.

permalink
report
parent
reply
10 points

I would say it’s more like: “How can I do X?” “Here are some reasons you can’t do Y.”

The answers should have been “Here are some reasons doing X is hard, but here’s an attempt at it anyway and also some more robust alternatives to doing X.” That would have been an excellent answer. (If you go down far enough you do start to see things like this but they’re hindered by people still responding that you can’t do Y or downvoting because they don’t understand what’s happening.)

permalink
report
parent
reply
6 points
*

More like:

  • How can I do X?
  • Marked as duplicate of “How can I do Y?”

Edit: I’ve got insomnia and don’t have my glasses on and misread the end.

permalink
report
parent
reply
1 point

Always start SO questions with X/Y problem pre-empting

These people are everywhere and will stop at nothing to make you click on one of these

https://xyproblem.info/ https://news.ycombinator.com/item?id=34444353 https://en.wikipedia.org/wiki/XY_problem

They are trying to derail your question, which was already a generalized version of what your actual question was. And of course, you would need to explain everything you generalized out of your question (which would probably all get deleted by someone editing your question and removing all the irrelevant facts) by which point your question becomes so complicated nobody can answer it, even though they could have answered the generalized version.

My advice, just use chatgpt or mistral, 99% you will get a better answer than stackoverflow. And you will get this actionnable answer IMMEDIATELY !

permalink
report
parent
reply
41 points

https://www.zalgo.org/

T̸̛̟͚͋͛̈̊͜͝Ờ̶̤̫̦͙̜̫͇͕͈̘̭̈̑̓̀̈́̌͊͛̆͐̌̈́͝ͅN̸̯̫̺̄̿̎͗͗́͜Y̷̢̱͚̖̤̠̞͉̅́̋̉̿̇̎̋͆͝͝ ̸̧̡̨̧̡̛̖̤̜͔̲̯̞͉͈̻̎̈̄̓̊̄́̕͘͝͠ͅT̷͎̝͌̅̔̓̒H̷̨̧̧̳̱̜͓̮͍̣̬̩̜̙͚̑̌́̑͋̽͗̎͑̊͛̍́͒̕͝͠Ḙ̵̥̥̘̻͔͛̑͒̿͋͝͝ ̶̡͚̬͈̏͌̓̔̈̔̀͌̔̓̾̓͘͝P̷͙̃́̈͐̆̂́͗̏͌̈́Ô̶͎͓̹͖̘̟̬͚̻̦̩͔͛͜͠ͅŅ̶͖̜̱͍̦̔̊͐͆̾̎́́̈́̄̓ͅẎ̸̨̭̜̼͎̜̜͕̥͙̼̤̟̞̄̊̂́ͅ ̴̡̡̛̲̟̳̯͔̝̟͙̌̽͋̏̾̆̅̏̐̅͑̿̀͒̉H̵̪̞̩̥̫̺̅̑̈́̾͌͛́̾̅̈͛͒̾̌̈͐͝Ȅ̶̘̲͙̖̬̞͕̱͍̥͈̦͈͍͔̩̑̒̐̇̑̈́̏͊̽͜͝͝͝ ̸̨̛̛̻̘̙̯̰̦̻͈͓̒̽̉̈̄̌̄͊͂̈͆ͅC̵͙̗̣̮͈̜̪̞̰̣͎̙̏̌̄͗͜Ȯ̸͇̖̼͈̗̝͔̜̘̲̦̦̾̃̆̍͝͝ͅM̷̨̧̮͕̠̘̔ͅÉ̶̡̡̢̡͕̺̗̩̝̩͇͓̄͐͆͛̔̈́̕͜ͅS̵̡͙̬͔̞̞̳͓̜͔͑̌̓̎͆͌̈͌̌̂͛̚͘͝

permalink
report
reply
6 points

d̶̢̢͖͉̪͖̠̹͇̺̜̼̦̗͍̓̅̊̋́̌̈́̌̐͐̔̅̄̚͜͝ͅͅȍ̷̢̧̦̼͉̝̦͓͖̽͜ǫ̷̫̤͐̀̾̈̇́̈́͛̐̔̀͜͜͝͝͠k̸̩̠̥̦̤̜͈͎̖̜̪̘͚̖̫̝̝͛̈́̇͒͜͝ͅì̷̧͈̥͇̤̝͈̹͕̽̑͌̐́̓̈́̈́ȩ̴̘̠͍͎̜̝̰̼̝̭̹͖͇͚̦͈̼̑̊͗́́̒͐̂̂̾̊̀͜͝

permalink
report
parent
reply
32 points

OP isn’t trying to parse HTML though… they are trying to detect opening xml tags. Which seems quite achievable with regex.

permalink
report
reply
1 point
*

It’s still actually pretty sketchy, depending on exactly what you want to do. Strict regex still won’t be able to match correctly if you want to match what an HTML parser considers the opening tag, though fancier regex will. If you’re just looking for the tags in the HTML document as a flat document it’s doable, though. (Mostly.)

permalink
report
parent
reply
14 points

Calendar, remind me to ask StackOverflow tomorrow if I can parse HTML with regexs get someone else to do my class homework for me?

TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ

Sweet, my summoning spell worked!

permalink
report
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create 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.

Community stats

  • 5.2K

    Monthly active users

  • 1.5K

    Posts

  • 35K

    Comments