Mega Code Archive

 
Categories / Ruby / String
 

Changing the Case of a String

s = 'HELLO, I am not here. I WENT to tHe MaRKEt.' s.upcase           # => "HELLO, I AM NOT HERE. I WENT TO THE MARKET." s.downcase         # => "hello, i am not here. i went to the market." s.swapcase         # => "hello, i AM NOT HERE. i went TO ThE mArkeT." s.capitalize       # => "Hello, i am not here. i went to the market."