in reply to Trailing spaces
will work fine for that, the $ anchors the pattern to the end of the string. Any other spaces that aren't at the end of the string are left as is.