0 points

splits and counts sentences even if there is punctuation like "!!!" and "....."


dashboard

Thu Dec 03 2020 20:21:58 GMT+0000 (UTC)

Posted by @theo #ruby

require 'pry'

class String

  def sentence?
    self.end_with?(".")
  end

  def count_sentences
    self.split(/\.|\?|\!/).delete_if {|w| w.size < 2}.size
  end
end
content_copy Copy

https://github.com/learn-co-students/ruby-oo-self-count-sentences-lab-dumbo-web-010620/blob/solution/lib/count_sentences.rb