这是我的字符串。它包含一些 HTML:
First sentence. Here is a <a href="http://google.com">Google</a> link in the second sentence! The third sentence might contain an image like this <img src="http://link.to.image.com/hello.png" /> and ends with !? The last sentence looks like <b>this</b>??
我想将字符串拆分为句子(数组),保留 HTML 以及分隔符。像这样:
[0] = First sentence.
[1] = Here is a <a href="http://google.com">Google</a> link in the second sentence!
[2] = The third sentence might contain an image like this <img src="http://link.to.image.com/hello.png" /> and ends with !?
[3] = The last sentence looks like <b>this</b>??
有人可以建议我这样做吗?可能正在使用正则表达式和匹配?
这非常接近我所追求的,但不是真正的 HTML 位: JavaScript Split Regular Expression keep the delimiter