Here's a cute little method I use for extracting blurbs from text. Specify a minimum character count as the argument, and the method returns a string containing the minimum text plus whatever it takes to reach the next period, question mark, or exclamation point.
reg = Regexp.new ".{}[,;:-_\\w\\s]*[\.\!\?]"
body.slice(reg)
end

0 comments:
Post a Comment