2013-06-19 7 views
1

目前我有这个正则表达式将一个段落拆分成句子:/[^\.!\?]+[\.!\?]+/g。但问题是我的段落不仅仅是文本的段落。我有一个像这样在他们的联系:如何构建将段落拆分为句子的正则表达式,但是不会拆分<>中的任何标点符号?

This is text and here is a <value="link" href="http://link.com?param=test"> which directs to another page. So I don't want to split at the anything inside the link above. 

我想是分成像数组:

['This is text and here is a <value="link" href="http://link.com?param=test"> which directs to another page.', 'So I don't want to split at the anything inside the link above.'] 

什么正则表达式将做到这一点?

回答

1

试试这个:

(.+?[\.!\?](?!.+?>)\s*) 
+0

这似乎是工作得很好,但忘掉过去的文本,如果它不能在预期的标点符号结束时分裂。 – Namey