Check string for words starting with the character @
<p>Hi there and thank you for taking the time to look into this.</p>

<p>I'm working on a comment system and instead of using nested comments, I just want to add the @user method for replies.</p>

<p>So let's say for example I enter this comment:</p>

<pre><code>@moonwalker: Thanks again for your reply.
</code></pre>

<p>I'm looking for a function to check if a word is starting with the character @ and after that changing the word into a link. The problem I'm facing is that people will use things like:</p>

<pre><code>@moonwalker: rest of the message

@moonwalker, rest of the message

@moonwalker rest of the message
</code></pre>

<p>or even use en email address in their comments.</p>

<p>Is there a simple way to achieve this? Preg_match perhaps?</p>

<p>Thanks in advance for your help.</p>
