ereg_replace bug?

I am making a Flash/PHP Guestbook! I have successfully done so but the automatic parsing of emails and urls have some problems! I am using ereg_replace() to search for and parse urls and email address but when a user has an email like some_guy@someguys.com it only considers the part after the underscore thus displaying the wrong email address: in this case would be guy@someguys.com!

Here’s the script I used!


$link = ereg_replace("[[:alpha:]]+@[^<>[:space:]]+
[[:alnum:]]","<a href=\"mailto:\\0\"><u>".$name."</u></a>", $link);

Hope you can help me!

Thanks for all who thought of a way to help. :smiley: I managed to solve the problem!

Instead of using:


$link = ereg_replace("[[:alpha:]]+@[^<>[:space:]]+
[[:alnum:]]","<a href=\"mailto:\0\"><u>".$name."</u></a>", $link);

I replaced it with:


$link = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.
([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<u><A HREF=\"mailto:
$1\">".$name."</A></u>",$link);