Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列の偶数文字のみを大文字にするにはどうすればよいですか?
私はもう試した:
str = "apples"; str.capitalize
"abcdefgh".gsub /..?/, &:capitalize => "AbCdEfGh" "abcdefgh".gsub /(?!^)..?/, &:capitalize => "aBcDeFgH"
元の文字列を変更する場合は、string.gsub!代わりに使用します。string.gsub
string.gsub!
string.gsub
string.scan(/..?/).map(&:capitalize) * ''