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"
Use string.gsub! instead of string.gsub if you want to modify your original string.
string.gsub!
string.gsub
string.scan(/..?/).map(&:capitalize) * ''
我想显示“用户”参加的旅行列表。我希望它分成“即将到来”和“以前的”表。目前它只显示数组列表中的所有行程。
我想创建一个 If Else 循环,它会说“如果日期稍后将列添加到该表”,否则“将列添加到该表”
信息: