eregi_replace问题!

时间:2009-11-28 16:54:58

标签: php regex posix

现在我有一个eregi_replace问题:

我有这个

$subject = "This is for @codeworxx - you have to try first!";
$text = eregi_replace('(((@))[-a-zA-Z0-9]+)','<a href="http://www.google.de/\\1">\\1</a>', $subject);
echo $text;

一切都很好,但是

<a href="http://www.google.com/@codeworxx">@codeworxx</a>

但我想要这个:

<a href="http://www.google.com/codeworxx">codeworxx</a>

怎么办?

谢谢, 的Sascha

1 个答案:

答案 0 :(得分:2)

<?php
$subject = "This is for @codeworxx - you have to try first!";
$text = eregi_replace('@([-a-zA-Z0-9]+)','<a href="http://www.google.de/\\1">\\1</a>', $subject);
echo $text;