Question

now i have an eregi_replace Problem:

I have this

$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;

Everything works fine, but the

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

but i want this one:

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

how to do?

Thanks, Sascha

Was it helpful?

Solution

<?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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top