在 "The <strong>dog</strong> is really <em>really</em> fat!
" 中匹配 "the dog is really really fat",并在其周围添加 "<span class="highlight">WHAT WAS MATCHED</span>
",是否可能?
我的意思不是具体指这个例子,而是一般情况下能够忽略HTML搜索文本,将其保留在最终结果中,只需在其上方添加 span,是否可能?
编辑:
考虑到 HTML 标签重叠问题,是否可以匹配一个短语,并仅在每个匹配的单词周围添加 span?问题在于当单词“dog”不在搜索上下文中时,我不希望它被匹配,例如“the dog is really really fat。”
<strong>我说这只</strong>狗真的很胖!你觉得呢?
你打算让它看起来像这样吗:<strong>我说<span class="highlight">这只</strong>狗真的很胖!</span>你觉得呢?
- BishopRook