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.