javascript - 如何构建一个将段落拆分为句子的正则表达式,但不会拆分 <> 内的任何标点符号?

标签 javascript regex node.js sentence

目前我有这个正则表达式将段落拆分成句子:/[^\.!\?]+[\.!\?]+/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.']

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

最佳答案

试试这个:

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

关于javascript - 如何构建一个将段落拆分为句子的正则表达式,但不会拆分 <> 内的任何标点符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17194643/

相关文章:

javascript - 在单独的文件中指定路线时无法找到路线

javascript - 在Safari 8中播放.MOV文件的HTML —发生了什么变化?

python - 如何解析日志文本文件、解析日期时间并获取时间增量总和

c# - 系统.UnauthorizedAccessException : Creating an instance of the COM component fails with error 80070005 (C#)

java - 通过正则表达式拆分字符串

用于匹配字符串选项的 Python 正则表达式

javascript - Node.js:不能从另一个调用一个 Javascript 原型(prototype)方法?

javascript - PDFObject 在 Firefox 中返回 false

javascript - Cypress 请求默认等待?

javascript - 如何显示输入中选定行的信息?