【发布时间】:2019-12-22 14:10:49
【问题描述】:
我正在寻找一种基于正则表达式使用 XML 节点动态包围部分文本的方法。
考虑以下示例
<speak>The test number is 123456789, and some further block of text.</speak>
现在假设我有一个针对数字的正则表达式,可以选择性地用一个新标签包围它,这样它就会变成:
<speak>The test number is <say-as interpret-as="characters">123456789</say-as>, and some further block of text.</speak>
我考虑过使用 DomDocument 来创建标签,但不确定替换部分。有什么建议吗?
【问题讨论】: