in reply to regexp problem

If you may assume the string contains at least two non-space characters, I'd write:
/(\S.*\S)/
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:
/(\b.+\b)/
which also works for strings containing just a single letter.
Perl --((8:>*