我有一个字符串
s = "Test TEst TEST. Test. TEST. TEST. Test test test."
我需要使结果像这样
s = "Test test test. Test. Test. Test. Test test test."
我怎么能在 ruby 上做到这一点?
谢谢。
s = "Test TEst TEST. Test. TEST. TEST. Test test test."
p s.split('. ').map(&:capitalize).join('. ')
#=> "Test test test. Test. Test. Test. Test test test."
s.gsub(/\w[^.]*/, &:capitalize)
# => "Test test test. Test. Test. Test. Test test test."