<?php
$comment = preg_replace('/@([^(@|\s)]+)/', '<a href="/$1">@$1</a>','@name1 kdfjd fkjd as@name2 @ lkjlkj @name3');
 
var_dump($comment);
?>