- Split sentence preserve punctuation
https://stackoverflow.com/a/15687656/2096740
Use scan
(throw strip in there to get rid of trailing spaces).
s = "I am a lion. Hear me roar! Where is my cub? Never mind, found him."
s.scan(/[^\.!?]+[\.!?]/).map(&:strip) # => ["I am a lion.", "Hear me roar!", "Where is my cub?", "Never mind, found him."]
- Simple detect puncutation in string