in reply to regexp problem
which will match the first non-space character, the last non-space character, and everything in between. If you may not make the assumption, I'd modify it slightly:/(\S.*\S)/
If you know the non-space characters will be letters (or digits or underscores), you can also write:/(?=\S)(.*\S)/
which also works for strings containing just a single letter./(\b.+\b)/
|
|---|