📅  最后修改于: 2022-03-11 14:55:25.901000             🧑  作者: Mango
class String
def count_sentences
scan(/[.!?]+(?=\s|\z)/).size
end
end
str = "Learning Ruby is great!!!! The course cost $2.43... How much??!"
str.count_sentences
#=> 3