s[^\s*(.*)\b\s*$][$1]
Update: Corion rightly points out that this does not work correctly for lines where the last non whitespace character is a non-words character. Eg.
the quick brown fox ( \n # ^
So, use s[^\s*(.*\S)\s*$][]; instead. It's slower, but still quicker than the FAQ method.
In reply to Re: trim leading & trailing whitespace
by BrowserUk
in thread trim leading & trailing whitespace
by ady
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |