71

From this question, I learned that SO has a special blurb that pops up when a question title containing "regex" is entered.

This is great to discourage "plz help! write this for me!!1" questions. However, it doesn't appear when "Regular expression" is entered. This seems like an easy thing to add, and it should help catch slightly-more-verbose questions of the same nature. It would also be useful: as of this writing, there are 123,817 questions that match "regular expression" when I search. Not all of them are of the type that this blurb is meant to catch, but still.

Could the regex blurb be made to appear when one of the following is present in the title?

  • regex (already present)
  • regexp
  • regular expression
  • regexes
  • regexps

@Braiam suggests watching the tags as well. There's a lot of regex-related tags, though, so someone would have to decide which ones indicate problem questions.

Maybe SO could use the following regex:

reg(ular\s+)?ex(p(ression)?)?

Of course, they could just ask someone on SO to write it for them if that one doesn't do the trick.

26
  • 75
    So, use a regular expression to recognize regular expression in a title... (yo dawg, I herd you liek...)
    – gunr2171
    Commented Aug 6, 2015 at 15:26
  • 1
    I was gonna add something to that effect, but I couldn't think of anything witty :) Commented Aug 6, 2015 at 15:27
  • 1
    @gunr2171 something like regex[\w]*|regular expr[\w]*? Need improving but hey it's a start.
    – ryanyuyu
    Commented Aug 6, 2015 at 15:30
  • 3
    @ryanyuyu I made one that is a little different, see my edit. Commented Aug 6, 2015 at 15:31
  • 9
    This looks like a regex question about regex questions. Which is therefore rather meta, in a post on meta.
    – Sobrique
    Commented Aug 7, 2015 at 13:58
  • 28
    We need meta.meta.stackoverflow.com Commented Aug 7, 2015 at 13:59
  • 2
    I would prefer that whenever the tag suggestions detect that is a regex question the blurb would appear.
    – Braiam
    Commented Aug 7, 2015 at 14:23
  • 8
    There are also abominations like "regex expression" or "regex expressions".
    – Kobi
    Commented Aug 7, 2015 at 14:33
  • 11
    You mean there are repetitive, redundant questions out there?! Commented Aug 7, 2015 at 14:34
  • @Kobi those would also be caught by the regex in OP's edit, since we're only looking for at least one match, rather than what the match is. Nice catch, and thanks for the humor!
    – andrewgu
    Commented Aug 7, 2015 at 15:45
  • 11
    You mean there are repetitive, redundant questions out there?!
    – dcsohl
    Commented Aug 7, 2015 at 15:50
  • I never knew about this! How is this blurb triggered and for what else is a blurb triggered?
    – Claudiu
    Commented Aug 7, 2015 at 16:21
  • @thirtythreeforty I was pretty disappointed when that didn't resolve.
    – canon
    Commented Aug 7, 2015 at 18:59
  • 2
    @gunr2171 Now you have (two)+ problems. Commented Aug 7, 2015 at 19:02
  • 2
    I think this has been suggested before, but I'm having trouble searching for it. I need a regex that matches regexes that match regexes.
    – Owen
    Commented Aug 8, 2015 at 6:56

1 Answer 1

13

Let's just detect the existence of regular expressions within the post itself with this simple regular expression:

/
^                                             # start of string
(                                             # first group start
  (?:
    (?:[^?+*{}()[\]\\|]+                      # literals and ^, $
     | \\.                                    # escaped characters
     | \[ (?: \^?\\. | \^[^\\] | [^\\^] )     # character classes
          (?: [^\]\\]+ | \\. )* \]
     | \( (?:\?[:=!]|\?<[=!]|\?>)? (?1)?? \)  # parenthesis, with recursive content
     | \(\? (?:R|[+-]?\d+) \)                 # recursive matching
     )
    (?: (?:[?+*]|\{\d+(?:,\d*)?\}) [?+]? )?   # quantifiers
  | \|                                        # alternative
  )*                                          # repeat content
)                                             # end first group
$                                             # end of string
/

How meta.

(shamelessly stolen from @MarkusJarderot)

8
  • 24
    That will only recognize valid regular expressions, which probably won't be found in the kind of questions we're trying to prevent. Commented Aug 8, 2015 at 6:33
  • This answer was firmly tongue-in-cheek; feel free to down-vote it as such. :p (clue: "simple regular expression")
    – Ben Claar
    Commented Aug 8, 2015 at 6:42
  • 2
    @BenJackson If it's not valid, then surely it's an irregular expression?
    – ClickRick
    Commented Aug 8, 2015 at 13:23
  • 15
    This comment is a valid regular expression. Commented Aug 8, 2015 at 16:11
  • 1
    @LucasTrzesniewski LOL, great point.
    – Ben Claar
    Commented Aug 8, 2015 at 16:12
  • 2
    @LucasTrzesniewski: You probably meant to escape the dot, though\. Didn't you\? Commented Aug 8, 2015 at 20:03
  • 5
    @Tim, nope. The string "This comment is a valid regular expression!" should totally match my previous comment. Commented Aug 8, 2015 at 20:17
  • 6
    I would also like to point out here that people asking for regular expressions might not actually have written one of their own. And that a question contains a regular expression doesn't necessarily mean the regexp is the problem. Yes, totally fun at parties, hi.
    – Jan
    Commented Aug 9, 2015 at 1:14

You must log in to answer this question.

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