33

This regex question was closed:

https://stackoverflow.com/questions/67873954/two-regex-rules-not-working-in-google-data-studio

Before it was closed, I answered the question, and I stand by that answer: I really think the question is fine as=is. It describes the problem correctly, it is about programming, etc.

Why was the question closed? Could someone help me to understand what is wrong with it?


Despite the big discussion around the problem and the number of upvotes showing the question should not be closed, the question was marked as a duplicate of a SQL-related question (the original question is about Data Studio syntax, not SQL, although they share some similarity), and more recently it was completely deleted (?!?!). WOW! What's happening?

35
  • 2
    How do you know the OP didn't want both regexps to only ever work in conjunction? (That seems sort of the gist of using CASE - even if misguided.)
    – mario
    Commented Jun 8, 2021 at 3:18
  • 11
    Its not a question about regex at all. It's simply the person not understanding how CASE works in SQL. Its very far away from being a regex question and therefore should be closed. If they had actually asked about CASE instead, it would probably have been a duplicate of an existing SQL question eg stackoverflow.com/questions/4622/sql-case-expression-syntax and therefore also should be closed.
    – JK.
    Commented Jun 8, 2021 at 4:01
  • 51
    @JK. Even if what you say about the question not being about regex at all is true, then that doesn't prove that the question should be closed. It means only that the question should be edited (including retagging) to better reflect what its actual topic is. And, if it's a duplicate, then that would be a valid closure, but the fact that a question is a duplicate does not (ever) justify closing it for any of the other close reasons.
    – Cody Gray Mod
    Commented Jun 8, 2021 at 4:26
  • 9
    I think it's part of a more broad problem of questions being answered -- and "answered" meaning the problem was solved -- and then being closed without appreciation of time invested by answerer, and without giving the answeree opportunity to acknowledge the problem was solved indeed. Commented Jun 8, 2021 at 7:12
  • 20
    @Sergey "Closed" doesn't have anything to do with whether or not a question has been answered.
    – Cody Gray Mod
    Commented Jun 8, 2021 at 7:13
  • 8
    @CodyGray People come here for help and to provide help. SO moderates in between. The key in my comment is "broad". Something is broken in process design. Commented Jun 8, 2021 at 7:18
  • 27
    The site is only designed and intended to support certain types of questions, @Sergey. The scope is extremely narrow. Questions that exist outside of that scope should not be answered here, regardless of whether or not they could be or someone wants them to be. Closure is how Stack Overflow deals with questions that do not meet our requirements, which are all stated clearly in the help center. Stack Overflow is not a help desk. We are not here to help people directly. We are here to build a library of high quality Q&A. That this also helps people is a nice side-effect.
    – Cody Gray Mod
    Commented Jun 8, 2021 at 7:32
  • 6
    I tried to salvage the question. Are you sure that you fully understood the problem in the question? It's not completely clear to me what the asker wanted to achieve. I guess the purpose might have been to apply two rules instead of only the first one... but maybe not. Maybe the answer was a bit premature. Commented Jun 8, 2021 at 8:21
  • 3
    There was no question in that post.
    – philipxy
    Commented Jun 8, 2021 at 11:26
  • 11
    @Dexygen Meta Stack Overflow is a place for discussing issues that affect the main site. That goes for big and small matters. It's the place where the community can make policy, contest moderator decisions, ask for questions to be closed/reopened, and otherwise raise their concerns. It's also, of course, a place where people can go to report bugs and get support with using the site's features. I think it's quite unfair to call any of that "whining", although a fair bit of whining certainly does happen on Meta. Importantly though, this question doesn't need to have any more general application.
    – Cody Gray Mod
    Commented Jun 8, 2021 at 14:56
  • 7
    With respect @CodyGray, many of the community members feel the exact opposite way: they come here to help people, and any contribution to building a database of Q&A is "a nice side-effect". Commented Jun 9, 2021 at 0:43
  • 3
    @SteveBennett And many feel the opposite way of that: They come here to contribute to a knowledge database, and helping individual people is "a nice side-effect". Commented Jun 9, 2021 at 5:17
  • 4
    @sneep There are tons of questions that are answered+accepted even though they should be closed. I've just cobbled together a canned comment for typo-answers, only to give up right away after becoming aware just how many there are. Just because people cannot close these fast enough does not mean they are fine. Commented Jun 9, 2021 at 8:44
  • 3
    @JonSG We do both. We directly help people and we indirectly help even many more people. The question askers get answers and all visitors get answers too. If I'm not mistaken that was exactly the mission from the go. Now the question is here to whom questions belong, just to the asker or to everyone equally? Commented Jun 11, 2021 at 7:27
  • 2
    That's why I said "implements the sql spec to some extent". And as far as we are aware, case statements are implemented the same way they are in sql.
    – Braiam
    Commented Jun 19, 2021 at 14:24

4 Answers 4

52

I have no idea why that question might have been closed.

Regex questions that are perceived as asking for a regex to be written are often closed for this reason, rightly or wrongly, but this question wasn't even asking for a regex to be written.

It was asking for an explanation of the reasons behind an observed behavior, and it gave what seems to me to be a minimal, reproducible example of that behavior. It mentioned what regex engine was being used (Google Data Studio). I don't know what other information it might have been lacking.

I'm posting this answer first, instead of unilaterally voting to re-open, because I am not a regex expert, and I might be missing something obvious. At least one of the close-voters is someone whose opinions I generally trust, so I think it's appropriate to hold off on re-opening and give folks a chance to explain what I might be missing. But please do explain, if you think this question needs to stay closed!

8
  • 16
    The question misses the input, and it fails to describe the actual problem. "It doesn't work" is not a problem description. In my book that's not a minimum reproducible example. Commented Jun 8, 2021 at 6:21
  • 3
    Adding example strings and the expected output would have been enough to avoid closure.
    – beerwin
    Commented Jun 8, 2021 at 6:39
  • 28
    I do not see why input examples are required. There is plenty of information provided to understand the question. The problem description is quite clear. It says a lot more than "it doesn't work".
    – Cody Gray Mod
    Commented Jun 8, 2021 at 7:15
  • 26
    @GeertBellekens: The actual problem description given was "but only the first rule works. If I swap the order of the rules, this rule applies, but not the second one." That's vastly more specific than "it doesn't work" - it's fairly strong evidence that the OP wants both of them to apply to the same string, not just one or the other, otherwise there wouldn't be a problem to ask about. It's not a good MCVE, but the answer was able to explain exactly what the answer does so future readers can just look at the answer. Commented Jun 8, 2021 at 7:16
  • 6
    Agreed that burden should normally be on the querent, so it's not exactly worthy of an upvote, but it's not unanswerable. Commented Jun 8, 2021 at 7:16
  • 10
    @PeterCordes that is a whole lot of guessing, or at least more than I'm willing to do. I still agree with the close votes. Commented Jun 8, 2021 at 8:33
  • 6
    @GeertBellekens: I don't think it was ambiguous enough to justify a close vote on that basis. It certainly doesn't seem like much of a stretch to me; it's certainly the obvious thing that would explain someone having asked that question. I likely wouldn't have answered, perhaps pending confirmation of what was wanted, but a keener version of myself that wasn't yet tired of answering low-effort / minimal-quality questions probably would have. Commented Jun 8, 2021 at 9:00
  • "I am not a regex expert" ...a regexpert ?
    – zedmelon
    Commented Mar 3 at 18:15
35

Regular Expressions is a tough topic for many users, and it's completely possible that someone asks a questions that shows they don't understand the matter well. I think this question is such a case. Therefore, it makes sense that the user has not asked a high-quality question that checks all the requirements for input/output on it.

However, the question does give some very clear clues:

  1. What is not working?: "Two REGEX-Rules not working"
  2. Where is the problem?: "in Google Data Studio"
  3. What has the user tried?: "I used these combined REGEX-Rules"
  4. What has worked?: "but only the first rule works."
  5. Has the user tried something else? "If I swap the order of the rules, this rule applies, but not the second one"

I think this information is enough to qualify as a legitimate question in the RegEx topic. We can safely make an assumption that the user wants both rules to work. The answer provided by @Diego Queiroz is a good answer and has the potential to help the user a lot:

  1. It clarifies how the CASE statements work
  2. It clarifies how regular expressions will match
  3. It gives an optimization
  4. It gives an alternative regular expression that can potentially satisfy the user (but we should leave this to the user to decide).
1
  • 5
    It's not an amazingly high quality question but also nothing wrong with it. But it's not a legit question in the regex tag because the issue is really about CASE statements, the fact regex is being used is completely incidental to the actual issue. And how CASE statements work is something with a million answers already, so it should be closed as a duplicate.
    – 404
    Commented Jun 8, 2021 at 16:10
14

So, here's the thing: regex has nothing to do with the question at hand. A better MCVE would be the following:

case
  when Seite = 1 then 0
  when Seite = 2 then 1
  else -1
end

Yes, the question has a regex, and no, it's not relevant, as the answer provided (and the example above) made clear. But the case statement is not actually the problem either. The problem is that the OP wants to conditionally replace two strings and were thinking that case statements are the solution (the answer already tells them this). The title almost captured this, but then the asker involved regex and now there's an extra problem that shouldn't be there.

If users were more willing to edit out the problem with the solution and instead surface the underlying problem, it wouldn't be closed.

That seems like a representation of what the question wants:

I have strings that can start with /amp/ or end with hyphen plus some integers (like -654654). I want to remove these from my data. How do I do this?

Relevant read:

11
  • 3
    Well the "you" here is not the one who asked the question on the main site, they are the one who answered the question. Commented Jun 8, 2021 at 15:09
  • 5
    @AbdulAzizBarkat well, answerers complaining that questions they answered are closed, instead of editing them.... it's like we created a badge specifically for this...
    – Braiam
    Commented Jun 8, 2021 at 15:12
  • It looks like this was intended as an answer on main site question. Commented Jun 8, 2021 at 17:27
  • 3
    It's worth pointing out that when you do use tags, you should generally read the wiki to make sure you've included all necessary details in your question. If the wiki is asking for details that are totally irrelevant to your question, then you probably shouldn't be using the tag. Reading the regex tag wiki would have headed off a lot of confusion.
    – JDB
    Commented Jun 8, 2021 at 17:54
  • @JDBstillremembersMonica or the regex users should just remove it like java/javascript, c/c++/c# and python.
    – Braiam
    Commented Jun 8, 2021 at 17:56
  • 3
    @FélixGagnon-Grenier no, I'm saying that the question is poorly framed.
    – Braiam
    Commented Jun 8, 2021 at 17:57
  • 2
    @Braiam - Yeah, I'm not condoning the drive-by closure. But given the notoriously poor quality questions in the regex tag, I can understand why reviewers get so trigger-happy when closing questions that don't meet a minimum bar. No example inputs? Close. They don't bother to take the extra time to notice that it's not actually a regex question.
    – JDB
    Commented Jun 8, 2021 at 17:58
  • 7
    @JDBstillremembersMonica meh, I don't blame them. When everything you see is garbage, it's difficult recognizing something that isn't.
    – Braiam
    Commented Jun 8, 2021 at 18:32
  • @Braiam indeed, now that I read my edited version, that intent becomes clear ;-) Commented Jun 8, 2021 at 20:18
  • ... damnit I almost successfully camouflaged a post from Peter's piercing gaze. I'll get the extra spaces some day. ( space intentionally left because what you gonna do? flag my comment to edit the space out?!!! :D ) Commented Jun 8, 2021 at 20:20
  • 2
    @Félix Who needs flags when there are moderators floating about who are also grammar pedants? ;-)
    – Cody Gray Mod
    Commented Jun 9, 2021 at 0:26
8

As one of the close voters in the question, adding the 2 criteria that I look for in questions:

  1. Current Field / Values

  2. Expected Field / Values

For example:

Current Field Expected Field
/abcd/amp/-1234 /abcd/
/text/amp/-1234 /text/

A RegEx attempt is optional. Currently, the question only has a RegEx attempt.

As mario noted in the comments, "How do you know the OP didn't want both regexps to only ever work in conjunction?". The issue with answering a question without the current and expected values is that there is a risk that a user creates and answers their own understanding of the question - it creates ambiguity thus may be less useful for future users (in the current state).

12
  • 16
    You have a valid point about what you wish to see when looking at regex questions. But did you add a comment to that effect to the question? Without that comment, how could the OP ever know what you wanted to see?
    – slugster
    Commented Jun 8, 2021 at 4:42
  • 1
    @slugster: Noted! I tend to add a quick comment or upvote an existing one when voting to close questions (and answers) and then remove it once the question is closed (not entirely sure whether I had done so in this specific close case).
    – Nimantha
    Commented Jun 8, 2021 at 4:50
  • 15
    What's your main goal with being strict about these rules, even in cases like this where we can be 99% sure we can figure out what the querent wants? Limiting the tide of low-quality questions that don't "deserve" answers if the person didn't put in much effort to following our standards? Or were you really primarily concerned with future readers being able to find the questions, and not cluttering up SO with low future value because of being hard to search? If it's clear enough (even just barely) but too low effort, IMO we should just downvote. Commented Jun 8, 2021 at 7:22
  • 2
    Given that the answerer chose to take on the burden of responsibility of explaining exactly what their answer does, that removes the risk of future readers thinking they found what they wanted; you always have to read the question or answer to figure out whether your problem is the same, not just the title. I agree normally the burden of explaining what is/isn't wanted should be on the querent, but an answer can do it. Commented Jun 8, 2021 at 7:24
  • 1
    @PeterCordes: The aim was to get get clarity on the current and expected values; as noted by Trilarion "I tried to salvage the question. Are you sure that you fully understood the problem in the question? It's not completely clear to me what the asker wanted to achieve. I guess the purpose might have been to apply two rules instead of only the first one... but maybe not. Maybe the answer was a bit premature." Also, note that I had voted to close the question when it was first created, and only saw the answer in the morning (after the question was closed). The post has also been reopened
    – Nimantha
    Commented Jun 8, 2021 at 8:39
  • 3
    On reading the question myself, I'm 99% sure I understand what they wanted, which seems sufficient. A better [mcve] would be nice, but I disagree there was enough ambiguity to justify closing. Future readers with a problem that matches Diego's answer might well find it. (I probably wouldn't have bothered to answer a relatively low-effort question that seems to have missed the point of the switch/case concept, though, but I've been around on SO for years and already posted at least one version of what I have to say about a lot of things. The title does seem reasonable searchable.) Commented Jun 8, 2021 at 8:53
  • 3
    Anyway, I understand that was your thought process and judgement at the time; thanks for explaining it. Commented Jun 8, 2021 at 8:54
  • 2
    @PeterCordes: Thanks :) Understand what you're saying as well (had chosen MCVE - Minimal Complete Verifiable Example as the close reason), as the purpose was to gain clarity on the current and expected fields to reproduce the issue and find a solution. to reiterate, had voted to close before an answer was posted as the intention was to have an MCVE so that fellow users could provide a suggestion.
    – Nimantha
    Commented Jun 8, 2021 at 9:08
  • 7
    Close voting this question is not the right thing to do in this case. All the reasons I'm reading for closing this question are actually reasons to remove the regex-tag and explain to OP that you removed the regex tag because the regexes aren't the issue, their understanding of the Google-spreadsheets scripting language is the issue.
    – asontu
    Commented Jun 8, 2021 at 14:02
  • @asontu: Noted and for future reference, Braiam has just updated the respective question and added a suggestion on the points raised.
    – Nimantha
    Commented Jun 8, 2021 at 15:45
  • 5
    @asontu If regex is removed, it is clear duplicate of SQL CASE question. No matter how you turn it, it should be closed.
    – Dalija Prasnikar Mod
    Commented Jun 10, 2021 at 6:42
  • 1
    @DalijaPrasnikar clear to you and me because we understand the shared syntax between SQL and Google Data Studio, not clear to OP who is using Google Data Studio, not SQL. So at the very least the question should then be closed as a duplicate of an existing SQL question with explanation for OP that the answer of that question is, in fact, applicable to their Google Data Studio question.
    – asontu
    Commented Jun 19, 2021 at 23:33

You must log in to answer this question.

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