例如,我有一个像这样的字符串:
我希望你能为没有给出绝对域的所有href添加绝对URL。
$html = '
<a href="test.html">test</a>
<a href="http://mydomain.com/test.html">test</a>
<a href="http://otherdomain.com/test.html">test</a>
<a href="someothertest/otherdir/hi.html">hi</a>
';
我希望你能为没有给出绝对域的所有href添加绝对URL。
$html = '
<a href="http://mydomain.com/test.html">test</a>
<a href="http://mydomain.com/test.html">test</a>
<a href="http://otherdomain.com/test.html">test</a>
<a href="http://mydomain.com/someothertest/otherdir/hi.html">hi</a>
';
最好的方法是什么?我想可能与正则表达式有关,但我的正则表达式技巧不太行 ;)
提前感谢!