-11

In regards to the below question, I want to understand why it was closed as "too broad".

As far as regex questions go, this is the most focused, verifiable, and clear question I have ever seen. No room for interpretation. If there is any room for interpretation, or providing any other answer that is more than a stylistic change, what is it?

Technically, it had issues before it was edited (just less clear, it said the exact same thing the whole time); But it was closed almost 2 hours after the final edit, which means that the question, in its current form, was deemed 'too broad', by multiple people.

Also, if this really isn't too broad, I doubt anyone would flag it if it came up in audit, so should it be reopened or left as is? (Does the audit system have anything to protect itself from bad audit questions?) I can't vote to open, so does that mean I should flag it for moderator review?

Here is a copy of the question.

So I have a regex pattern that works well. I wanted to see if I could make it better.

Here it is:

"(SEGMENTA)(.*?)(SEGMENTB)(SEGMENTB)(SEGMENTB)"

So this looks for any pattern with (SEGMENTA) (anything) (SEGMENTB)(SEGMENTB)(SEGMENTB).

But is there also a way to say that I want it to bring back if it only has this"

"(SEGMENTA)(.*?)(SEGMENTB)"

Essentially the last 2 ending SegmentB can be optional.

29
  • 4
    doesn't look like the first 3 bullets as mentoned in the tagwiki under How to Ask are fulfilled. Too broad it is.
    – rene
    Jul 28, 2017 at 13:38
  • 7
    I have no idea what this means: "But is there also a way to say that I want it to bring back if it only has this"" If you know what it means, you should edit the question. Jul 28, 2017 at 13:41
  • 1
    "I can't vote to open, so does that mean I should flag it for moderator review?" No. Do not use custom moderator flags for things the community can handle. Your meta post is sufficient.
    – ryanyuyu
    Jul 28, 2017 at 14:02
  • @rene I don't get what you mean. He said what he tried, he said what he wants, there are no duplicates (that I can tell); What wasn't fulfilled?
    – Tezra
    Jul 28, 2017 at 14:07
  • @CodyGray The edit queue was saturated at the time and then I kinda forgot about it. Edited it now, but the question title really says all you need to know.
    – Tezra
    Jul 28, 2017 at 14:09
  • 2
    I don't see what his tried input is, I don't see what his current output and expected output is, I don't see which dialect they are requesting the regex for. Okay, I'll give you that between the couple of current regex questions on the site it is possible no dupe exists. my bad.
    – rene
    Jul 28, 2017 at 14:11
  • @rene It opens with the regex he has now... true it doesn't include sample input and output, but the question is so simple, do you really need it to understand the question? (Would it help if I edited that in for future readers?)
    – Tezra
    Jul 28, 2017 at 14:14
  • 2
    My main problem is that, to me, if this question is unclear, almost all regex questions should be closed as 'too broad' because almost all the answers start with 'if you allow me to make these assumptions...'
    – Tezra
    Jul 28, 2017 at 14:21
  • Concerning assumptions: Your answer is missing the assumption, that OP used the capturing groups just for fun. Jul 28, 2017 at 14:24
  • 4
    @Tezra If almost all regex questions can't actually be answered given the information provided in the question, then yes, they should be closed. That there's lots of bad questions doesn't make them any less bad.
    – Servy
    Jul 28, 2017 at 14:25
  • @SebastianProske The OP also didn't say what OS/program he is running. I think it's safe to say that that doesn't affect the answer. It is also a trivial adjustment to switch from non capturing to capturing groups. The OP said he only cared about matching 1 or 3 times, so that is all the answer needs to address. I kinda feel if you are going to nitpick about what the OP DIDN'T say, than half of SE should be closed as too broad. In which case, why are people being 100X more strict about the rules for this question as apposed to all other regex questions? What stands out with this one?
    – Tezra
    Jul 28, 2017 at 14:32
  • Well, there is a deleted answer on that question with a single comment from a mod. That is what stands out.
    – rene
    Jul 28, 2017 at 14:44
  • So let me try asking something else, aside from adding input and expected output examples, how can this question be improved to make a good question? (As any information that isn't explicitly stated, can easily be added by anyone, pretty much just from reading the question title)
    – Tezra
    Jul 28, 2017 at 14:46
  • 1
    Too bad tag burnination isn't something a mod can do @CodyGray otherwise I would have a backlog for you to handle after regex ...
    – rene
    Jul 28, 2017 at 14:59
  • 1
    What I'd really like to know is why you think it isn't too broad. Suppose for a second that this were a question about C, C++ or JavaScript that covered similar grounds. Would it be too broad then, or would it still fit on-topic?
    – Makoto
    Jul 28, 2017 at 16:38

2 Answers 2

14

It's too broad, and here are two reasons why:

  1. He didn't read the excerpt

    We don't write tag excerpts just for fun. My top peeve on SO? People who don't read and then get shocked when their posts get downvoted/closed/deleted. Here's the regex excerpt (emphasis mine):

    Regular expressions provide a declarative language to match patterns within strings. They are commonly used for string validation, parsing, and transformation. Since regular expressions are not fully standardized, all questions with this tag should also include a tag specifying the applicable programming language or tool. NOTE: Asking for HTML, JSON, etc. regexes tends to be met with negative reactions. If there is a parser for it, use that instead.

    The only tag on that question is . So now you know. Pity it took a question getting red and blue lasered for that.

  2. The answer isn't useful

    So, there's POSIX and PCRE. But the question and answer are in…pseudo-code:

    SEGMENT((?:SEGMENT){2})?
    

    This takes regex, which is already hard enough to understand, and makes it even more arcane. If I want to use this…there's nothing to use. Yes, we sometimes have academic discussions, but keeping the content usable for other people is fairly important. The only good thing about this is he's not trying to parse HTML with it.

13
  • I like that this is grounded in something to prove objectively that the question does have an issue. There are a lot of regex questions that fail to specify a flavor. I kinda feel it should be ok for a basic question like this, where a solution that works in all flavors exists... but I can't flag every regex question that fails to list a flavor, can I? (The flag queue is saturated enough) I guess that's a question of how aggressive do you want to be with flagging.
    – Tezra
    Jul 28, 2017 at 17:01
  • 1
    @Tezra If a question has a problem, flag it. Don't worry about the size of the queue. And just because other bad questions remain open (6000+ questions asked per day overall) isn't a license to leave this one open.
    – Machavity Mod
    Jul 28, 2017 at 17:21
  • Is 'too broad' the appropriate flag here though? It seems like it is only a low quality question. I don't feel any of the flag accurately describe the issue (lack of OP effort mostly)
    – Tezra
    Jul 28, 2017 at 17:28
  • I take you back to my answer, tho. He's talking about a general regex principle. Had he posted a specific example, the question would have been acceptable. Specific is the antonym of too broad.
    – Machavity Mod
    Jul 28, 2017 at 17:31
  • 1
    Do note that the initial revision of said question did try to parse html ...
    – rene
    Jul 28, 2017 at 18:23
  • 2
    @rene It was edited before the pony could come, so it's all good
    – Machavity Mod
    Jul 28, 2017 at 18:27
  • @Machavity The original question text had specific text instead of filler text. (switched to the filler because comments got derailed by sight of html and had to be purged with holy fire). To be clear by specific example, are you saying that using specific text over filler would have made it a good question, or that a more specific question, that required a more complicated answer should have been asked?
    – Tezra
    Jul 28, 2017 at 19:14
  • @Tezra The original question wasn't that much more specific (it was still pseudo-code). Yes, he was parsing HTML, but what was he using to parse it? Java? PHP? PERL? It would have helped to have the question tagged, say, [java] and then give a full example in Java.
    – Machavity Mod
    Jul 28, 2017 at 19:53
  • What's pseudocode about that fragment?
    – jscs
    Jul 28, 2017 at 19:54
  • @JoshCaswell What's he running it in? And, as I noted earlier, what type of regex are we talking? So it's pseudo-code without context
    – Machavity Mod
    Jul 28, 2017 at 19:56
  • I agree, the flavor needs to be specified, but "pseudocode" seems a little strong.
    – jscs
    Jul 28, 2017 at 19:58
  • @Machavity In what regex engine does (x)(xx)? not work to match "1 or 3" in where x is any string constant? What regex flavor could change this behavior? What other non-stylistic changes could you possibly do to that? That is main reason I don't think that rule applies in this one case. I can understand this as bad as being too basic a question, but what information can you possibly add to the question to change that answer?
    – Tezra
    Jul 28, 2017 at 20:02
  • Also, the question never said anything about parsing. All the OP wanted, was "Match 1 or 3. not 2, not more, not less, just 1 or 3". He was matching a string pattern in a blob of text that just happened to resemble html. The match he wanted made no sense for any html parser either. So, this is really just an extremely specific, very basic regex question, where flavor happens to not affect the answer.
    – Tezra
    Jul 28, 2017 at 20:14
8

Funny you should mention this...

Here's why I feel like it's too broad:

  • The question is asking us to essentially write their regex with these specified constraints. That is, they have some working regex that satisfies their needs, but then they say that they need a different regex.
  • The question doesn't tell us what they've attempted, or where they're having trouble. All we get are the requirements, which aren't really...enough. Yes, we know that they want the last two fragments to be optional, but...okay, where are you having trouble with doing that in your regex?
0

You must log in to answer this question.

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