排除名「.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