I need to extract a shorter segment of text of a specified number of words from a longer one. I can do this using
text = "There was a very big cat that was sitting on the ledge. It was overlooking the garden. The dog next door watched with curiosity."
text.split[0..15].join(' ')
>>""There was a very big cat that was sitting on the ledge. It was overlooking"
I would like to select the text up to the next period so I don't end up with a partial sentence.
Is there a way possibly using a Regex to accomplish what I'm trying to do that will be able to get the text up to and including the closest next period after the 15th word?