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.
- if there is just
@
and nothing before and after that then it should not be replaced. @
in the emails should not be replaced. For eg.sam@example.com
should not be replaced.- Only strings like
@sam
or@example
should be replaced like<a href="http://twitter.com/sam">@sam</a>
and<a href="http://twitter.com/example">@example</a>
Please help. Thanks in advance.