10

This question had been closed for the second time. It is about manipulating string in order to remove occurrences of characters between brackets and parentheses including themselves.

Initially I closed this question with three duplicate questions:

  1. Remove Text Between Parentheses PHP
  2. Need help with regex to remove square brackets and anything between
  3. Remove spaces from the beginning and end of a string

One of the answerers re-opened the question and added some statements about leading spaces which previously the question had found a duplicate for (the third link):

enter image description here

Question is now re-opened for the second time and still to me it seems a question that matches a bunch of existing questions like these two:

  1. replace everything between {} [] () braces from a string
  2. and again Remove spaces from the beginning and end of a string

Why it shouldn't remain closed?

11
  • 6
    With new requirement you mean the "whitespace" part? I would argue that this requirement already existed, but wasn't explicitly mentioned. Keeping that wouldn't make sense and the example also didn't include a surplus whitespace at the end. But the change from "text inside brackets as well as the brackets" to "text inside brackets", on the other hand, is a very bad edit and that part should be rolled back.
    – Tom
    Commented May 12, 2019 at 10:59
  • 1
    If it already existed what is the importance of explicitly adding it to the question? Does it make it different from what it is right now? If not, shouldn't it remain closed? I agree that hinting to unwanted leading and trailing whitespaces in the answer is a good job but unless confirmed and required by OP why should be added directly to the question?
    – revo
    Commented May 12, 2019 at 11:14
  • 4
    I would ask OP if they can confirm on that requirement, of course, but stuff like this can become important when the answer must contain that and it can make a difference when it comes to the duplicate questions, if they actually are duplicates or not. But in a situation like this, where the difference is a simple trim() call, I wouldn't make a big issue out of that and still chose the same questions as dupe target and add a comment for the remaining trim part.
    – Tom
    Commented May 12, 2019 at 11:21
  • 1
    @Tom I just tried to reproduce the answer with the given answers in the duplicates but with no success. See my comment there.
    – Christoph
    Commented May 12, 2019 at 13:17
  • 3
    @Christoph How did you try? Using the first answer from 1st dupe leads to the right answer 3v4l.org/W31cO
    – revo
    Commented May 12, 2019 at 13:27
  • 1
    @revo: Your example leaves whitespace at the end. The explicitly stated requirements (ie: start vs. end) doesn't have whitespace at the end. Now granted, the original requirements also dropped the "2", but we can assume that's a typo. Commented May 12, 2019 at 15:25
  • @NicolBolas dropping 2 is a typo and as I said earlier in my post, number #3 of duplicates refers to trim() and as mentioned in comments that should be added to the list of duplicates or just someone should tell OP about it in comments. The main and emphasized problem is removing things that occur within a specific pattern.
    – revo
    Commented May 12, 2019 at 15:40
  • 1
    @revo I took the online tool from the answer and tried all three version: The one from the given answer and the two from the linked duplicated. The latter two didn´t work.
    – Christoph
    Commented May 12, 2019 at 19:13
  • 1
    @Christoph Sorry, I'm not sure if you were able to try the same code. I gave you a link to try it yourself.
    – revo
    Commented May 12, 2019 at 19:20
  • 2
    @AlexeiLevenkov I didn't even think that it may be this much ambiguous. I hope it is cleared now.
    – revo
    Commented May 12, 2019 at 21:02
  • 1
    Because "every question is sacred!" ...
    – user10677470
    Commented May 13, 2019 at 15:11

1 Answer 1

15

If it already existed what is the importance of explicitly adding it to the question?

To make it abundantly clear that the requirement is there, since clearly some people didn't notice. And thus presumably explain why it is not a duplicate of questions that don't have that requirement.

The OP of the question stated that, given a specific input, they wanted a specific output. That output, by all appearances, removed whitespace. Therefore, removing whitespace is part of the requirement, even if they were not originally spelled out in the text (and even though the OP quite frankly probably didn't realize it).

So they're not creating new requirements; they're emphasizing existing requirements which, in their opinion, makes the question ineligible to be a duplicate.

I feel like I'm not wrong in keeping the question closed and as the answerer is trying to put more than what is needed in the question they are not helping anybody at all.

I think that you are correct that the question should remain closed, but I also don't think the answerer is adding anything that was not already a requirement.

Even if the question is not a duplicate, it is understated in its desires, since it is not clear on what basis you would remove whitespace. That is, if bracketed text is between two non-bracketed text, how much whitespace do you preserve between them?


From the comments:

I don't have any problem with the edit (though I don't see it %100 right) but with the purpose behind it.

Just because someone is doing a thing to cause an action you don't agree with is insufficient justification for saying that a user cannot do that thing. Edits are good or bad on their own merits, not because of the reasoning for making them (in most cases). Edits are bad because they violate the spirit of the question, the intent of the OP, or generally make the post worse (or not improve it).

If you would find the edit to be unproblematic without the context of the duplicate issue, then it doesn't matter if the edit was made in an attempt to highlight that the editor does not think the question is a duplicate. The edit is valid.

34
  • 3
    @revo: But the requirement (to some extent) is there in the original. So it is not illegitimate to add text making it clear that the requirement is part of the question and not optional. So what exactly is your problem with the edit? Commented May 12, 2019 at 16:57
  • 1
    @revo: But the person making the edit clearly doesn't agree about the validity of the dupe closure, due to reasons explained in the edit. If the edit is valid (that is, it is merely expressing the OP's intent more clearly), then whether the question is a dupe or not rests on whether the edited version is a duplicate. Which it still is, but that's a different conversation. Commented May 12, 2019 at 18:07
  • 5
    @revo: "That reasons aren't valid and don't make sense." The reason why someone decided to make that edit is unimportant next to the question of whether that is a legitimate edit to make. If the edit is valid on its merits, then it is valid, full stop. If the edit was inventing details that were not part of the OP, that's one thing, but that is not the case. Commented May 12, 2019 at 19:21
  • 1
    @revo: "the main problem is not whitespaces" Define "main problem". Unless you're claiming that whitespace removal is a trivial addition (and as someone who's had to solve this kind of thing before, I can tell you it most certainly is not. Not if you want to handle more cases than just the one the OP posted), the problem is exactly what the OP outlined: removing the bracketed content in a way that leads from the input string to the output string. Since the output string didn't have whitespace that wasn't part of bracketed content, whitespace removal is part of the problem. Commented May 12, 2019 at 19:33
  • 1
    If you see the original question it is asking one thing and that is about removing occurrences of a pattern which has an exact answer here. If you want to tell me well then what about leading spaces? then I would say trimming leading spaces in PHP has an exact duplicate here. So this question should be closed by two dupes, right?
    – revo
    Commented May 12, 2019 at 19:38
  • 1
    @revo: You seem to be talking past me, so let's wrap this up. If the only reason you have to question the legitimacy of this edit is that the edit casts into doubt the legitimacy of the duplicates, tough. If the edit is valid on its merits, if it is not inventing content that wasn't there, then it is a legitimate edit to make. That's my position on the matter: an edit that seems to make a question less of a duplicate is not a bad edit just for that reason. It has to be a bad edit regardless of duplicate voting and the like. Commented May 12, 2019 at 19:44
  • 1
    You are talking about the edit as the main problem of this meta post, I'm talking about the reasons why it should get re-opened by just a simple edit that doesn't add anything new to the question and even if it does, it has a duplicate. You are talking about the edit mainly, I'm talking about its opening state.
    – revo
    Commented May 12, 2019 at 19:48
  • 1
    @revo: "I'm talking about the reasons why it should get re-opened by just a simple edit" And I'm saying the reasons do not matter. See my edited answer to make this clear; if the edit is valid, then it can be made, even if the edit is being made in an attempt to get the question reopened. You cannot disallow someone from taking a valid action just because you don't like the reasons behind that action. Commented May 12, 2019 at 19:52
  • 1
    @revo: Are you asking about whether the question should be re-opened, or whether its OK for a person to make that edit? These are not the same question, and the title of your question seems firmly focused on the latter rather than the former. Commented May 12, 2019 at 20:11
  • 6
    The question has been broken down into 4 sub-problems by the 300k+ rep, 5 times upvoted answerer. The answer there is higher quality than in any of the proposed dupes, as is the question. This is no more a dupe than any other regex question, because all regex questions can be broken down into subproblems, as the answerer did. So, instead of discriminating against this particular question and asker, why not try to be consistent- argue that regex questions are banned, and if that fails, treat them all the same way. Commented May 13, 2019 at 6:21
  • 1
    @revo, if the only legitimate questions in SO are atomic problems that can't be further broken down, then I don't think any regex question in SO is legitimate. All questions are variations on, why isn't this code working and send me teh codez pls. The concern about the possibility of duplicates seems secondary and redundant to me. Because none of those dupe targets should be there either, if SO's rules are being strictly enforced. Now, is it a realistic proposal? I doubt it. It is why I have argued that different rules for tags like regex are required. 1/ Commented May 13, 2019 at 10:50
  • 1
    @revo, I can't see the value to anyone, whether to the asker, to future readers in the archives, to maintainers like you, or to the answerers in that queue, of closing that question as a dupe. Maybe it is a dupe, maybe it isn't, but either way, I can't see the point. If we agreed that SO's rules are not enforceable, as they stand, in tags like regex (and if "enforceable" is to be understood as enforceable in a consistent way, then they're certainly not enforceable), the first thing I would change is dupes: it only makes sense in a tag like that to close as dupes questions that are ... 2/ Commented May 13, 2019 at 10:53
  • 1
    @revo, ... either cut & paste dupes; or questions that differ only by differences in the wording of the question or input data. In other words, on Jeff Atwood's terminology, I wouldn't allow "borderline dupes" like this to be closed in this tag, at all. it would be a big improvement. 3/3 Commented May 13, 2019 at 10:55
  • 1
    @NicolBolas, if you insist, it is a language, but a very small one with a very small related problem space. I have never personally found a regex problem that I needed help with. Either way, I don't think any of these regex questions have value to future readers in the archives. Back to my point then, what is the point of closing any of them as duplicates? This question here is "remove text between parentheses". It's not really a different problem than "remove text between X and Y". All regex questions, when broken down, become dot points on ... 1/ Commented May 13, 2019 at 15:17
  • 1
    @NicolBolas, that’s the problem with your reasonable user theory. To me, yes, it is as trivial to break these problems into their first principles as doing long division. And what is truly “trivial” is merely a matter of opinion. Certainly though, all problems in this tag are “send me teh codez” and “why isn’t this regex working”, including these alleged dupe targets, and almost none are of value to future googlers. Whether you understand regex ir not, you’ll almost never find the answer by googling. You either learn the language, or ask someone how to do it. Commented May 13, 2019 at 23:43

You must log in to answer this question.

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