PHP regexp:替换文本字符串中的一段URL
请帮助理解php正则表达式。请输入以下字符串:PHP regexp:替换文本字符串中的一段URL,php,regex,preg-replace,Php,Regex,Preg Replace,请帮助理解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_li
<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/和/某些文本之间的产品列表替换为,例如产品列表
谢谢你的帮助
谢谢如果您只需要做一件更易于使用的事情,您可以这样做:
$text = '<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>';
$new = '<img>product_list_replaced</img>';
$match = 'imagecache/';
$newstr= str_replace($match, $replace, $text);
$text='';
$new='product_list_replacement';
$match='imagecache/';
$newstr=str_replace($match,$replace,$text);
如果您对常规表达式感兴趣,请查看
嗯