Changing the Case of a String : String format « String « Ruby






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."

 








Related examples in the same category

1.use % for format printing
2.Substituting Variables Into an Existing String
3.Replace string with float
4.Center, left justify and right justify string