排除名“.html”我使用下面的preg_replace()调用替换为新的结构链接:的preg_replace从替代条款
preg_replace('/example.com\/sub-dir\/(.*)">/', 'newsite.co.uk/sub-dir/$1.html">', $links);
它几乎工作,但它不会对加名“.html”去年底更换,所以它最终成为类似‘newsite.co.uk/sub-dir/page-identifier’,而不是“newsite.co.uk/sub-dir/page-identifier。 HTML”。
我相信这是一些简单的我失踪,但谷歌搜索的问题并没有拿出任何有用的结果,所以我希望这里有人能帮助!
在此先感谢!
编辑:作为一个例子,这里是$链接侧连接
<a href="http://example.com/sub-dir/the-identifier">Anchor</a>
上面的例子,如果工作我改变了REGEXT但是到下面没有(*):
<a class="prodCatThumb" title="View product" href="http://example.com/sub-dir/product-identifier">
它结束了作为
<a class="prodCatThumb.html" title="View product" href="http://example.com/sub-dir/product-identifier">
任何想法?
你能告诉我们'$ links'的内容是什么? – anubhava 2012-04-26 11:51:42
@Ashley:请看看我的编辑,因为我为你解决了这个问题 – Nikola 2012-04-26 12:26:14