You need to modify the case of a string, up, down, or capitolized.
! s = “this Is A weird Sentence” ! s.upcase # uppercase ! s.downcase # lowercase ! s.capitalize # capitalize first word, downcase rest ! s.swapcase # reverse the case of each alpha character ! # don’t forget all of the bang equivalents (eg upcase!)
The string class has a full complement of modification methods including upcase, downcase, capitalize, and swapcase. Each one of those also has a “bang version” (a ruby method-naming idiom where it modifies the object in place rather than returning a modified copy).
- perl’s y///, uc, lc will take care of upcase, downcase, and swapcase.
- You’ll have to write a regex to handle capitalize.
Status: In Progress