【发布时间】:2015-09-08 07:13:46
【问题描述】:
我碰巧到处搜索,但没有找到使用 Ruby 计算字符串中句子数量的解决方案。有谁怎么做?
例子
string = "The best things in an artist’s work are so much a matter of intuition, that there is much to be said for the point of view that would altogether discourage intellectual inquiry into artistic phenomena on the part of the artist. Intuitions are shy things and apt to disappear if looked into too closely. And there is undoubtedly a danger that too much knowledge and training may supplant the natural intuitive feeling of a student, leaving only a cold knowledge of the means of expression in its place. For the artist, if he has the right stuff in him ... "
这个字符串应该返回数字4。
【问题讨论】:
-
stackoverflow.com/a/18089658/517483 可能会有所帮助。
-
你如何定义“句子”?