54

Disclaimer: I have a stake in this question, as I'm the owner of the accepted answer.


I'm disappointed with the process that's happening on this question about a regex-related error message in TypeScript, and I'd like some input:
Category shorthand not allowed in this regular expression dialect in Typescript

The OP is getting a very specific error message about his regex, but he doesn't understand how to fix it. The solution is relatively simple: Use supported syntax instead.

1st closure: Now, this question was first Dupe-hammered as a duplicate of:

That dupe target is just a broad canonical about how character classes work in JavaScript.
Imho, that dupe target was a poor fit, as it doesn't even mention the invalid shorthand syntax. I've stated as much in a comment to the original close-voter, but they chose to ignore that.

After that, the question was re-opened as a result of my re-open vote, and another gold badge owner's vote.

2nd closure: After that, the question was closed as a duplicate, again. This time targeting:

That target is once again not asking the same question, nor does it mention the error message or the regex shorthand the OP is using in the question or any of the answers...


Now, what triggered me to finally ask this on Meta, was the fact that this question has gotten a delete vote.

To me, it feels like this is "just another regex question to be deleted on sight".

We don't delete duplicates, and this question isn't exactly bad.

It's not a "Write my regex for me / debug my regex" question.
It has a clear error message.
That exact error message does not return any search results other than that question, even though it's not compiler/IDE-specific. Apparently it's not often experienced.

Sure, the question is simple, but it's specific.

Now, if someone finds a dupe that takes care of explaining why that error message is shown, or why that shorthand is invalid, I'd fully support the closure, but I ask you this:

  • Should this question be closed with such a generic dupe?
  • Should this question be deleted, if closed as a dupe?
28
  • 7
    I don't see how that new duplicate target answers the Question.
    – Scratte
    Commented Oct 27, 2021 at 17:43
  • 12
    After reading the question and answer, I feel like I just picked up another problem in my life. Commented Oct 27, 2021 at 17:47
  • 12
    I am not an expert, but this seems like very specific question with very specific answer that explains error. I wouldn't dupe close it unless there is another question asking about same error directly. Proposed dupes don't match.
    – Dalija Prasnikar Mod
    Commented Oct 27, 2021 at 17:52
  • 17
    "We don't delete duplicates" eh, not strictly true, there is a point where a duplicate question is so low quality that it can't even be a useful sign post. (though i don't believe that applies here, the delete votes are likely just an effort to prevent reopening.) I don't actually see any current delete votes on the question.
    – Kevin B
    Commented Oct 27, 2021 at 18:04
  • 3
    @KevinB There was one when this meta was posted. There was an upvote though, so the delete vote doesn't appear anymore, as the post is not eligible for deletion currently.
    – cigien
    Commented Oct 27, 2021 at 18:07
  • 5
    As to there being different error text presented for a similar issue, that such things exist is one of the reasons we have duplicates, so that people looking for a problem using different keywords will be directed to a solution which has already been supplied on another question. So, in the general case, that different error text is produced doesn't justify that it's not a duplicate. If it is a duplicate, the error text definitely justifies the question as a signpost.
    – Makyen Mod
    Commented Oct 27, 2021 at 19:17
  • 7
    The second answer on the dup-target question, Regex to Match only language chars (all language)?, does directly explain/show the syntax for Unicode property escapes, at least as far as JavaScript is concerned.
    – Makyen Mod
    Commented Oct 27, 2021 at 19:17
  • 10
    This looks like a case of something I've ranted about a million times. Two questions having the same answer does NOT imply that they're the same question! Commented Oct 27, 2021 at 20:17
  • 4
    Two questions with different words also doesn't imply they're not the same question.
    – Kevin B
    Commented Oct 27, 2021 at 20:18
  • 8
    @KevinB A good rule of thumb is that even if two questions are fundamentally the same question, if you cannot recognize that they're the same question before knowing the answer, then both should be kept. Commented Oct 27, 2021 at 20:19
  • 3
    @KevinB That's precisely the reason for my argument. Questions should be retained representing a sufficient subset of all possible ways of encountering the same problem that anyone who searches for any variation will find at least one Q&A. This would probably reduce the number of new duplicates. Commented Oct 27, 2021 at 20:23
  • 3
    *and they should be directed to the best answer, rather than having the same answer spread out across dozens of duplicate questions.
    – Kevin B
    Commented Oct 27, 2021 at 20:27
  • 11
  • 5
    Tangentially related: A plea against regex dogmatism.
    – mklement0
    Commented Oct 28, 2021 at 2:47
  • 3
    The "rules" for when questions are closed as duplicates or left answered appear inconsistently applied. The "rules" for which duplicates are deleted are left undeleted appear inconsistently applied. I imagine it must appear absurdly unfair and unkind to new users.
    – jxh
    Commented Oct 28, 2021 at 20:43

2 Answers 2

34

So this is also why I don't like just closing dupes for the sake of closing dupes. If there's some nuance here that needs to be explained/illustrated/pointed out that's lost in the dupe, then it's pretty important to surface it and advocate for it.

To this question, since I'm not a SME on Regex (I just like looking at graph-based tools that tell me how things break down so I feel like I know something), my recommendation would be as follows.

  • If the duplicate covers ground that is reasonably applicable to the OP's use case, and can serve as a direct and reasonable answer to it, then close it as a dupe.
  • Otherwise, don't close it as a dupe.

Deleting dupes just because they're dupes is also a bit of an antipattern, and I would want to discourage that within the first two weeks of a question existing. Give it a bit of time so that the community can really establish if this is or is not a good sign post, if it's a sign post at all.

6
  • 1
    (Imho, this question is about feature support for TypeScript (and by extension JS), more than it's about regexes themselves)
    – Cerbrus
    Commented Oct 27, 2021 at 17:42
  • 5
    @Cerbrus: Exactly, that's the nuance that's lost in a generic dupe closure just about regexes. So it should likely stay open, in my assessment.
    – Makoto
    Commented Oct 27, 2021 at 17:43
  • 6
    "Give it a bit of time so that the community can really establish if this is or is not a good sign post, if it's a sign post at all." Unfortunately, that hardly ever happens in the [regex] tag. Most questions closed as duplicates get deleted as soon as the -3 score threshold is reached (which is probably done by the users who subsequently vote to delete anyway). Upvoted questions also get deleted once the two-day threshold is reached as documented in the linked meta post.
    – 41686d6564
    Commented Oct 27, 2021 at 23:39
  • 4
    There have been times that I dupe-hammered something (in [python], where I have the hammer) and also upvoted it, because I thought it was an exceptionally good signpost. Commented Oct 28, 2021 at 2:21
  • 6
    "Give it a bit of time so that the community can really establish if this is or is not a good sign post, if it's a sign post at all." This can be easily gamed by regex answerers (who prefer to close nothing -- unless someone else answered before they did) who have a "handful of upvoting buddies". <-- not hypothetical. What we really need are regex SMEs who are not striving for that ridiculous 1M rep target and who actually try to curate content by isolating the problem and finding a duplicate among the millions of pages available. Commented Oct 28, 2021 at 5:01
  • 7
    @mickmackusa I appreciate your comment, but there is also a "handful of downvoting buddies" who does with the sole intention of deleting a question. I am pretty sure that if all of the current regex answering persons (excluding the elite group) take a break from SO for 6 months, probably all of their regex posts will be deleted. If this is about getting some fbuymeacoffee, I can buy them 50 coffee per year to allow me to post in regex without getting deleted :-)
    – akrun
    Commented Oct 28, 2021 at 16:09
-22

This is a poor question, it's basically "here's my code, here's my error, fix it". No context of why the regex looks how it looks, no explanations of why the OP wants that particular regex, what they want to achieve with it. It's an XY Problem.

It should be closed as needing more details, or needs debugging. But I agree that it should not be closed as a duplicate if indeed it's not a duplicate.

The question also has an tag, which has nothing to do there, so maybe we should also focus on other stuff besides adding responses, if we want to salvage the question.

10
  • 24
    I disagree that it should be closed for needing more details or needing a MCVE/MRE. The code supplied is sufficient to duplicate the error supplied (with a minor amount of clearly obvious additional code to define the object and property being tested). While lots of "write my regex for me" Qs substantially lack details needed to be able to actually design the regex, that's not the issue here, because it's not what's being asked for. So, while the regex being used might be totally inapplicable for the overall thing it's being used for, that doesn't matter for the question being asked there.
    – Makyen Mod
    Commented Oct 27, 2021 at 19:22
  • 3
    This is a reason to close it as too broad/unclear, not as dupe!
    – Braiam
    Commented Oct 27, 2021 at 19:31
  • 5
    RE: the Angular tag, TS is the primary language of Angular, so it could be that OP is writing this while working in an Angular application, and suspects that it might be related to Angular. It's a reasonable tag to include until someone who is a SME on the matter conclusively says it's not related, IMO.
    – TylerH
    Commented Oct 27, 2021 at 19:32
  • @Braiam was your comment directed at me, or at other "commenters"?
    – Cristik
    Commented Oct 27, 2021 at 19:35
  • 1
    @TylerH I fully understand the OP adding the tag, my remark was addressed to us, the others, that have the expertise.
    – Cristik
    Commented Oct 27, 2021 at 19:36
  • 1
    @Cristik Well, given you have >2k rep, and seem to be indicating you have expertise, why not remove the tag yourself? :-)
    – TylerH
    Commented Oct 27, 2021 at 19:38
  • @TylerH don't tempt me, I have some ideas to also "improve" the code snippet :P
    – Cristik
    Commented Oct 27, 2021 at 19:44
  • @AlexeiLevenkov then in that case should we transform this question into a canonical one for future ones that stumble into the same error?
    – Cristik
    Commented Oct 27, 2021 at 20:04
  • 1
    You have stated that the linked post is a "here's my code, here's my error, fix it" type of question, but also argue that "It's an XY Problem". You might (or might not) be correct on either one of those claims, but you can't possibly be correct on both.
    – skomisa
    Commented Oct 29, 2021 at 6:46
  • 1
    @skomisa the two are not exclusive
    – Cristik
    Commented Oct 29, 2021 at 7:51

You must log in to answer this question.

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