$, anything before the $ in the regex will be what is captured. Since it wants to remove a word at the end of the string, it uses \w to capture any letter. The + will make it keep on going until it finds whitespace or a symbol. The [.!?] is unneeded, but it just there to make sure it'll match with "Example hello.", "Example hello!" And "Example hello?"
That was good and understandable explanation thanks.
One thing also how its know that it got the last word of string and then it trace back?
Обсуждают сегодня