我正在使用正则表达式以将文本分成句子。这是我的代码:
elem.replace(/([.?!])\s+(?=[A-Z])/g, "$1|").split("|");
问题是例如缩写之类的。 “申请号”或“文档”。被认为是一个句子。 有什么方法可以防止这种行为?
有人知道例如如何修改正则表达式以仅当一个句子包含多个单词时才拆分?
var text= "hello eveyone. This is a text, with a Abbreviation. Appl. No. is 2134."
result=text.replace(/([.?!])\s+(?=[A-Z])/g, "$1|").split("|");
/*
Result is "hello eveyone., This is a text, with a Abbreviation., Appl., No., is 2134."
But it should be:
Result is "hello eveyone., This is a text, with a Abbreviation., Appl. No. is 2134."
*/