"BOCA RATON".gsub(/\w+/){|w| w.capitalize}
is even shorter 
cheers
Simon
···
-----Original Message-----
From: Carlos [mailto:angus@quovadis.com.ar]
Sent: Monday, March 13, 2006 2:31 PM
To: ruby-talk ML
Subject: Re: Quickest way to do this string op.
eastcoastcoder@gmail.com wrote:
> What's the quickest way to turn "BOCA RATON" into "Boca Raton"?
"BOCA RATON".replace "Boca Raton" # 
Probably
"BOCA RATON".split(/\b/).map{|s| s.capitalize }.join
It is quick to write, at least...
HTH
Hi,
I'm new to Ruby but can't you just use :
"BOCA RATON".capitalize
?
Cheers,
Pete
···
On Mon, 2006-03-13 at 22:34 +0900, Kroeger, Simon (ext) wrote:
> -----Original Message-----
> From: Carlos [mailto:angus@quovadis.com.ar]
> Sent: Monday, March 13, 2006 2:31 PM
> To: ruby-talk ML
> Subject: Re: Quickest way to do this string op.
>
> eastcoastcoder@gmail.com wrote:
>
> > What's the quickest way to turn "BOCA RATON" into "Boca Raton"?
>
> "BOCA RATON".replace "Boca Raton" # 
>
> Probably
>
> "BOCA RATON".split(/\b/).map{|s| s.capitalize }.join
>
> It is quick to write, at least...
>
> HTH
"BOCA RATON".gsub(/\w+/){|w| w.capitalize}
is even shorter 
cheers
Simon
Answer : No you can't. Please ignore me 
···
On Mon, 2006-03-13 at 22:36 +0900, Peter Palmer wrote:
Hi,
I'm new to Ruby but can't you just use :
"BOCA RATON".capitalize
?
Cheers,
Pete
On Mon, 2006-03-13 at 22:34 +0900, Kroeger, Simon (ext) wrote:
>
> > -----Original Message-----
> > From: Carlos [mailto:angus@quovadis.com.ar]
> > Sent: Monday, March 13, 2006 2:31 PM
> > To: ruby-talk ML
> > Subject: Re: Quickest way to do this string op.
> >
> > eastcoastcoder@gmail.com wrote:
> >
> > > What's the quickest way to turn "BOCA RATON" into "Boca Raton"?
> >
> > "BOCA RATON".replace "Boca Raton" # 
> >
> > Probably
> >
> > "BOCA RATON".split(/\b/).map{|s| s.capitalize }.join
> >
> > It is quick to write, at least...
> >
> > HTH
>
> "BOCA RATON".gsub(/\w+/){|w| w.capitalize}
>
> is even shorter 
>
> cheers
>
> Simon
>
Peter Palmer <ppalmer@naniteservices.co.uk> writes:
I'm new to Ruby but can't you just use :
"BOCA RATON".capitalize
irb(main):001:0> "BOCA RATON".capitalize
=> "Boca raton"
Regards,
Tassilo
Nope! (That gives => "Boca raton").
And, even as a Ruby newbie, I determined in seconds.
The real point of my post is to say that, while I'm learning Ruby, I have IRB
open in a konsole right next to kmail--it's very nice to quickly plug a piece
of code in there and do some testing (confirm it works, take bits off the end
to see intermediate results, etc.).
regards,
Randy Kramer
···
On Monday 13 March 2006 08:36 am, Peter Palmer wrote:
Hi,
I'm new to Ruby but can't you just use :
"BOCA RATON".capitalize
Peter Palmer wrote:
Answer : No you can't. Please ignore me 
Do we ignore the message asking us to ignore you?

Anyway, you were on the right track, but the string needs to be chunked on white space, then regrouped.
"BOCA RATON".split( /\s/ ).map{ |w| w.capitalize }.join( ' ' )
If one tends to do this a lot, it can be added as an instance method to String:
class String
def titlize
self.split( /\s/).map{ |w| w.capitalize }.join( ' ' )
end
end
"BOCA RATON".titlize
···
--
James Britt
“Design depends largely on constraints.”
— Charles Eames