15

There is a regex that should automatically remove all greetings from the top of posts. It does its job very well:

^                 # begins at start of body
\s*               # possible spaces
(
hii?(?![a-z])|    # any of these greeting words
hello|
h(e|a)y(?![a-z])|
dear|
greetings|
hai|
guys|
howdy|
h(i|e)ya|
hola
)
.*?               # followed by anything, up to...
(
[.,;!-]+          # one or more bits of punctuation
\s*               # possible spaces
|
(\r?\n)+          # one or more newlines
)



I propose we add one for "thanks" and related endings. Here is my draft:

\s*
(
(and\s*)?(\+\s*)?(with\s*)?
(so\s*)?(many\s*)?(mu?ch\s*)?
(lots\s*(of\s*)?)?
((tha?nk)|(thx)|(thnx)|regard)s?\s*
(you\s*)?
(in adva?nced?\s*)?
((a\s*)?lots?\s*)?
(((very\s*)|(so\s*))?mu?ch\s*)?
((and\s*)?(\+\s)?regards?\s*)?
[\.\!]*\s*
([\:\;]\s*[\-\~\=]*\s*[\)\]\}\>D3]+)* #smilies :) :D ;-3 etc.
[\.\!]*\s*
)
$

I am sure there could be many improvements, but it's a start. And it will save many an editor's time.

And because I couldn't resist the irony:

Thanks!

  • Will this erase some or all of the following? Here is my code: [newline] <begin code block>MyString = thanks – Brian Webster Mar 3 '13 at 7:14
  • Also see: meta.stackexchange.com/a/93989/212673 – Brian Webster Mar 3 '13 at 7:15
  • @GeorgeWBush That's a very rare if not impossible case in which the code would have to end at the very end and the code would be setting a variable to "thanks" for some reason. Also in most programming languages you would need single or double quote around it. @ your second comment Err... that's what I put in my question – Doorknob Mar 3 '13 at 13:15
  • In my example, "thanks" would also be a variable name. It's not impossible, but is is extremely rare. I posed it because I was trying to poke holes in your regex. Is it worth breaking 1 honest codeblock in order to auto-remove 1 million superfluous signatures? Code blocks and block quotes should probably be immune – Brian Webster Mar 3 '13 at 16:19
  • 1
    @GeorgeWBush Yes. Yes, of course it is. Who names their variables "thanks," anyway? I'll search code for "thanks" and see what pops up :P – Doorknob Mar 3 '13 at 16:20
  • 3
    Apparently we get many "Thanks"s in code instead of plaintext: stackoverflow.com/questions/12588746/… (I found a bunch with search: code:thanks) – Doorknob Mar 3 '13 at 16:21
  • 4
    I agree but disagree. Some may think it's impolite not to say that. What I hate is when someone gains reputation for removing "Thanks." Do you get promotions at jobs for removing "Thanks" in a coworker's email when replying? People that do it to me the most usually cannot gain from edits anymore, but it is very possible to gain rep just for removing a greeting (which doesn't really add to the answer/make it easier to understand). Like someone else said on another post, a three letter "Hi," isn't going to reduce the quality of the post and prevent people from vising: it's polite. – Anonymous Penguin Mar 9 '13 at 17:52
  • 3
    Is there nothing better to work on or improve on StackExchange, than to remove people for thanking each other??! What has this world come to :-O hahah – d-_-b Mar 9 '13 at 18:28
  • 1
    +1 simply for d? in adva?nce?d. That drives me nuts. However, I predict this could have a high rate of failure or false positives, perhaps too much to be worth it. – user159834 Mar 9 '13 at 19:02
  • This would be great, thanks – Ben Brocka Mar 9 '13 at 21:28
2

I think that having this implemented would make a great start on improving the professional appearance of questions on every Stack Exchange site.

The Tour of every site already says that there should be no chit chat, and I think unnecessary thanks are an example of chit chat.

A Meta Stack Overflow Q&A that resonates with me is No Thanks, Damn It!

  • 1
    The "remove greetings" filter has had issues. I'm sure a thanks-removing filter will find new and exciting ways to mangle posts. – Mark Jun 20 '18 at 23:21

You must log in to answer this question.

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