【发布时间】:2014-02-05 02:01:29
【问题描述】:
我需要一些帮助来编写正则表达式来拆分包含一些标签的字符串(不是真正的 HTML,我只是使用 <i> 和 <b> 标签来格式化一些文本),并保留分隔符。例如这个字符串:
<b>a bold quote:</b> this is some sample test. How <i>do</i> I do this?
将转换为:
<b>a bold quote:</b>
this is sample text. How
<i>do</i>
I do this?
【问题讨论】:
-
这让我想起了下面的 stackoverflow 经典 RegEx match open tags except XHTML self-contained tags .. regex-infection 会吞噬你的 HTML 解析器等...