Trying to replace all @mention occurrences with an anchor tag while I have:
$comment = preg_replace('/@([^@ ])? /', '<a href="/$1">@$1</a> ', $comment);
Take the following sample line:
"@name kdfjd fkjd as@name @ lkjlkj @name"
So far so good, but I want to ignore this single "@" character. I tried using "+" and "{2,}" after "[^ @]", which I thought would provide a minimal number of matches, but it does not work.
source
share