高手帮我看下这段程序怎么没有实现替代的效果
<?php
$text="this is a link to http://www.wjgilmore.com/.";
echo ereg_replace("http://([a-zA-Z0-9./-]+)$","<a href=\"\\0\">\\0</a>",$text);
?>
我的目的是显示带有<a http://www.wjgilmore.com>http://www.wjgilmore.com</a>
<?php
$text="this is a link to http://www.wjgilmore.com/.";
echo ereg_replace("http://([a-zA-Z0-9./-]+)$","<a href=\"\\0\">\\0</a>",$text);
?>
我的目的是显示带有<a http://www.wjgilmore.com>http://www.wjgilmore.com</a>
$subject = "abcdef";
$pattern = '/^def/';
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);
print_r($matches);
?>
$r = "<a href=\"\\0\">\\0</a>";$t = "this is a link http://asdf.asdf.asdf/";echo preg_replace($p,$r,$t);
echo ereg_replace("http://[a-zA-Z0-9./-]+[^/.]/","<a href=\"\\0\">\\0</a>",$text);this is a link to <a href="http://www.wjgilmore.com">http://www.wjgilmore.com</a>.你本身的也是正确的,只不过格式上有点问题
echo ereg_replace("http://([a-zA-Z0-9./-]+)$","<a href=\"\\0\">\\0</a>",$text);
得到
this is a link to <a href="http://www.wjgilmore.com/.">http://www.wjgilmore.com/.</a>
对比一下差异,当然这无碍大局