http://www.perlmonks.org?node_id=589837


in reply to Re^4: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
in thread Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)

Trimming the string is still necessary in order to comply with the specs. Yes, very boring ;-)
function reverseWords(str) { return str.replace(/^\s+/,'').replace(/\s+$/,'').split(/\s+/).revers +e().join(' '); };
--
AltBlue.