用符号或符号替换附加 html 标记值
<span class="fwb">Harry and David</span>
<span class="fcg">Business Intelligence Developer/Analyst</span>
<span class="fcg">Oct 1998 to present</span>
<span class="fcg">Medford, Oregon</span>
<span class="fsm fwn fcg">Creative writing</span>
In my html content
<span class="fwb"> occured more than 4 times,
<span class="fcg"> occured more than 10 times,
<span class="fsm fwn fcg">Creative writing</span> occured more than 5 times.
使用 php reg 表达式或 DOMDocument() 我需要用 $ 符号替换要附加的所有内容。
例如:
<span class="fwb">Harry and David</span> to be replaced by <span class="fwb">Harry and David$</span>
<span class="fcg">Business Intelligence Developer/Analyst</span> to be replaced by <span class="fcg">Business Intelligence Developer/Analyst$</span>
<span class="fwb">Harry and David</span>
<span class="fcg">Business Intelligence Developer/Analyst</span>
<span class="fcg">Oct 1998 to present</span>
<span class="fcg">Medford, Oregon</span>
<span class="fsm fwn fcg">Creative writing</span>
In my html content
<span class="fwb"> occured more than 4 times,
<span class="fcg"> occured more than 10 times,
<span class="fsm fwn fcg">Creative writing</span> occured more than 5 times.
using php reg expression or DOMDocument() i need to replace the all the content to be appended with $ symbol.
For ex:
<span class="fwb">Harry and David</span> to be replaced by <span class="fwb">Harry and Davidlt;/span>
<span class="fcg">Business Intelligence Developer/Analyst</span> to be replaced by <span class="fcg">Business Intelligence Developer/Analystlt;/span>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的代码示例中很难理解(?),但我相信您希望在每个
标记的末尾附加一个
$
符号。使用DomDocument
来执行此操作:您可以,正如你所说,也使用
preg_replace()
像这样:此正则表达式示例将
$
附加到主题 HTML 文本中每个 span 节点的末尾。It's difficult to understand from your code samples (?) but I believe you're looking to append a
$
sign to the end of each of the<span>
tags. UsingDomDocument
to do this:You could, as you said, also use
preg_replace()
like so:This regex example appends
$
to the end of each span node in the subject HTML text.