in reply to It's all getting messy - remove whitespace
The regular expression \s+$ means "one or more whitespace characters at the end of the line" so it will never match whitespaces in between other characters.
Whenever I want to strip excessive whitespace from a string, I usually go about it in a three-step way:Add a few comments and the job is done.
Perhaps this can be combined into a single-shot regex but it will probably be harder to read and waste more CPU cycles to accomplish exactly the same thing. I never bothered to find out because this approach works for me.
Time flies when you don't know what you're doing
|
|---|