Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by AltBlue (Chaplain)
on Dec 14, 2006 at 15:04 UTC ( #589837=note: print w/replies, xml ) Need Help??


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(' '); };
  • Comment on Re^5: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://589837]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2017-04-29 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (533 votes). Check out past polls.