I am developing a PHP application which needs a regular expression to replace the @ mentions like twitter. Also the regular expression should satisfy the following needs.
Wow. I found the answer myself guys.
$tweet = preg_replace('/(^|[^a-z0-9_])@([a-z0-9_]+)/i', '$1@$2', $tweet);
Thanks for your help guys.