How to parse user mentions in PHP
<p>I am developing a system where user enters his message in following format:</p>

<p>Hey @john are you coming in birthday party of @elise?</p>

<p>here as soon as you type @ in text box dropdown appears and you can select desired name from that.</p>

<p>My problem is is while posting the message it should be HTML code like this.</p>

<pre><code>Hey &lt;a href="http://www.mysite.com/user/id/123"&gt;John Doe&lt;/a&gt; are you coming in
birthday party of &lt;a href="http://www.mysite.com/user/id/789"&gt;Elise Lisa&lt;/a&gt;?

preg_replace("/@([A-Za-z0-9_]+)(?=\?|\,|\;|\.|\s|\Z)/", &lt;new_html&gt;, &lt;old_string&gt;);
</code></pre>

<p>So how do I find all the occurrences of @ in string and process them?? Since I need to pass a function call getUserName($shortname) and getUserID($shortname) where $shortname is text after @. Also I need to call the function NotifyUser() for every call of the respective shortname.</p>
