我有一个正则表达式将一个段落分成句子:
var sentences = /[^\.!\?]+[\.!\?]+/g;
[\.!\?]+
如果标点符号 ( ) 后面有空格,我希望它只匹配\s
。我试过/[^\.!\?]+[\.!\?]+\s/g
了,但没有奏效。
我想要这个的原因是因为目前如果中间有一个带有标点符号的单词(如about.me
),它会在那里拆分它,就像它没有.
代表句子的结尾一样。有任何想法吗?
例如:
如果我有这一段:
If the problem being solved isn't as apparent or immediately useful as traffic about.me and navigation data: weather. A few apps are trying to harness the crowd to provide accurate?
我希望它只分裂成
['If the problem being solved isn't as apparent or immediately useful as traffic about.me and navigation data: weather.', 'A few apps are trying to harness the crowd to provide accurate?']
而目前它分为
['If the problem being solved isn't as apparent or immediately useful as traffic about.', 'me and navigation data: weather.', 'A few apps are trying to harness the crowd to provide accurate?']
.