How Do I Trim Whitespace at the End of Text Lines?

You're close. The way to tell Keyboard Maestro to treat $ as the end of each line instead of the end of the entire string is to start the regular expression with (?m). Also, if you want to delete all the horizontal whitespace characters, you should use the + quantifier, which means "one or more." Therefore,

(?m)\h+$

is what you want.

1 Like