PHP regexp:替换文本字符串中的一段 URL
请帮助理解 php 正则表达式。有这个字符串:
<a href="/kop/product/acer-timeline-5810tg-944g50mi" class="imagecache imagecache-product_list imagecache-linked imagecache-product_list_linked"><img src="http://localhost/kop/sites/default/files/imagecache/product_list/Acer-Timeline-1.jpg" alt="Acer As Timeline 5810TG-944G50Mi" title="Acer As Timeline 5810TG-944G50Mi" class="imagecache imagecache-product_list" width="100" height="100" /></a>
我需要替换中位于imagecache/和/SOME_TEXT之间的product_list标签,例如
product_list_replaced
如有任何帮助,
谢谢
Please help with understanding php regular expressions. Have this string:
<a href="/kop/product/acer-timeline-5810tg-944g50mi" class="imagecache imagecache-product_list imagecache-linked imagecache-product_list_linked"><img src="http://localhost/kop/sites/default/files/imagecache/product_list/Acer-Timeline-1.jpg" alt="Acer As Timeline 5810TG-944G50Mi" title="Acer As Timeline 5810TG-944G50Mi" class="imagecache imagecache-product_list" width="100" height="100" /></a>
I need to replace product_list that situated between imagecache/ and /SOME_TEXT within <img>
tag, with, for example product_list_replaced
Any help appreciated
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只是需要这样做,那么使用 str_replace(),您可以这样做:
如果您对正则表达式感兴趣,请查看此站点< /a>
哈!
If you just need to do that is easier to use str_replace(), you can do it this way:
If you are interested in regular expresions take a look of this site
HTH!