in reply to Replace a word in a line except for the last char of the word?

A few notes on your code:

Hope you live a happier life because of this :-)