问答详情
源自:3-7 正则表达式的搜索和替换

为什么结果是This is a link to http://www.wjigilmore.com/.?

<?php

$text = "This is a link to http://www.wjigilmore.com/.";

echo preg_replace("/http:\/\/(.*)\//","<a href = \"\${0}\">\${0}</a>",$text);

?>

不是应该是This is a link to

<a herf ="http:// www.wjigilmore.com/"> http://www.wjigilmore.com/<a/>.吗?

提问者:慕粉1220028519 2017-04-22 10:46

个回答

  • _归03591539
    2017-04-23 17:55:32

    注意是替换掉了