77

Edits with hair don't stick

As you can see I made an edit but it won't stick and gets deleted right away; another user with 20k rep also tried to make the same edit with no luck.

This is the answer where it happened. Also I have copied it to the answers in this question; feel free to try and edit it by adding Hair, to the front.

2
  • 9
    Probably caused by the auto salutations removal.
    – Antony
    Oct 21, 2015 at 3:58
  • 56
    Off the top of my head, pretty sure this is powered by a regex, so fixing this will potentially be a ... ⌐■_■ ... hairy situation.
    – Adam Lear StaffMod
    Oct 21, 2015 at 4:05

4 Answers 4

33

Hair,

You can get a temporary workaround by adding an invisible comment using <!-- --> at the beginning of your answer. Then you can add 'Hair' after it. I agree though that this needs to be fixed.

7
  • 1
    Making it bold also works. Oct 21, 2015 at 19:30
  • or adding <img></img> before
    – Aequitas
    Oct 22, 2015 at 2:22
  • @ShadowWizard Yes, but you can see that. This is invisible.
    – wythagoras
    Oct 22, 2015 at 16:40
  • See here, adding unicode character "Zero Width Space" also works. I'll post a comment consisting only of those so it's easier to copy, let me try.. oh, not making it easier to copy. Ways to type this character are described here. :) Oct 22, 2015 at 17:44
  • 17
    ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ Oct 22, 2015 at 17:44
  • @ShadowWizard and here if you're not using a laptop keyboard, ie alt08203
    – Aequitas
    Oct 23, 2015 at 3:31
  • 1
    @ShadowWizard - surely you meant bald*= Oct 24, 2015 at 9:10
20

We have performed a Hair removal removal.

Hair is no longer trimmed, cut, stripped, or buzzed.

2
  • 4
    Is there any hope that Jeff Atwood's answer will be updated to include the new regex?
    – user642796
    Nov 16, 2015 at 18:49
  • I was a bit confused about whether this is a joke post until I went to geoff's profile and saw he was a staff.
    – starball
    Apr 17 at 19:50
15

Considering the regex used seems to be:

^                 # begins at start of body
\s*               # possible spaces
# any of these greetings
(hii?(?![a-z])|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
|                 # or
   (\r?\n)+       # one or more newlines
)

Replacing the .*? by something that matches less should fix it. My suggestions:

  • (\W.*?)? makes sure that any of the bad words is followed by a non-word character before matching anything else
  • \b.*? makes sure we're at a word boundary before matching the rest

Putting it together and removing superfluous bits

^                 # begins at start of body
\s*               # possible spaces
# any of the following greetings
(h[ai]i?|hello|h[eai]ya?|dear|greetings|hai|guys|howdy|hola)
\b                # word boundary, to not match words that begin with a bad word
.*?               # followed by anything, up to...
(
   [.,;!-]+       # one or more bits of punctuation
   \s*            # possible spaces
|                 # or
   [\r\n]+        # one or more newlines
)

Of course, you should check this against your unit tests. You do use unit tests, don't you?

And this would still match a useful answer on [workplace.se] that reads

Greetings should be exchanged as soon as you enter the room for your interview.

or

Dear or howdy is much too informal for a letter to a supplier.

or, over on [musicfans.se]

Guys 'n' Dolls is probably the band you're looking for.

So I agree that a pop-up alerting the user might be better.

1
12

The icy ball form of precipitation - induce the same bug.

The regex is attempting to defeat an initial "hai" (as in o hai), but it is overzealous.

The regex being:

^                 # 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
)
6
  • 1
    Running that regex against /usr/share/dict/words, the only problematic entry is hai, which matches a variety of "hail" and "hair" words (plus "Haiti" and "Haitian"). dear matches a few, but they're all uncommon or are derivatives of "dear" such as "dearest". Nothing else generates false positives.
    – Mark
    Oct 24, 2015 at 1:52
  • 2
    Running it against the list of article titles on Wikipedia, hai is again the main problem one, although hola generates a fair few false positives as well. dear and hello generate a bunch of hits, but they're almost all titles in the form of greetings, except for variations on "Dearborn".
    – Mark
    Oct 24, 2015 at 1:57
  • 3
    How about hay, in a hypothetical answer on the bio stack, on what to feed cows?
    – SQB
    Oct 25, 2015 at 23:01
  • 11
    Hay una problema with banning "hay" for the Spanish site too, probably Oct 26, 2015 at 10:53
  • 7
    The regex should not modify the post text but just display a popup saying "Please don't include salutations" or something alike. This would 1) educate the user, and 2) allow for legitimate word usage in case of false positive.
    – Konamiman
    Oct 26, 2015 at 11:57
  • 3
    looool do people really try to start posts with "hai"???? (wow that regex is terrible... at least chuck in a \b for goodness's sake!!!) Oct 28, 2015 at 1:39

You must log in to answer this question.

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