Converting upper-case string into title-case using Ruby

Posted by wsb3383 on Stack Overflow See other posts from Stack Overflow or by wsb3383
Published on 2009-11-24T17:30:17Z Indexed on 2010/05/28 14:42 UTC
Read the original article Hit count: 166

Filed under:

Hi, all.

I'm trying to convert an all-uppercase string in Ruby into a lower case one, but with each word's first character being upper case. Example:

convert "MY STRING HERE" to "My String Here".

I know I can use the .downcase method, but that would make everything lower case ("my string here"). I'm scanning all lines in a file and doing this change, so is there a regular expression I can use through ruby to achieve this?

Thanks!

© Stack Overflow or respective owner

Related posts about ruby