Categories
How to capitalize every word except one?
There are addresses like ' BARRON WI 54812-9126', RICE LAKE WI 54868-9344'; How can I capitalize every word in such a string, but WIalways keep both letters capitalized?
BARRON WI 54812-9126
RICE LAKE WI 54868-9344
WI
Answer the question
In order to leave comments, you need to log in
str.gsub(/\b[A-Z]+\b/) {|m| m == 'WI' ? m : m.capitalize}
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question