📜  String#count_sentences 返回复杂字符串中的句子数失败错误:expect(complex_string.count_sentences).to eq(4) - 不管代码示例

📅  最后修改于: 2022-03-11 14:55:25.901000             🧑  作者: Mango

代码示例1
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