现在我有一个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

有帮助吗?

解决方案

<?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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top