Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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?
[Corion]: marto: Yeah - taking a week off from the kids might be a plan :-D
[choroba]: what island?
[Corion]: choroba: La Palma on the Canary Islands
[choroba]: Ah, we went to Lanzarote 2 years ago with the kids and it was OK
[Corion]: choroba: I was there last year, yes, that would be suited a bit better for kids - much more beach and more varied kids friendly landscape than La Palma :)
[Corion]: We went to visit the "recently" (1975?) active volcano on La Palma but the landscape was underwhelming, at least when compared to the (cold) lava fields on Lanzarote

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2018-02-23 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (303 votes). Check out past polls.

    Notices?