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.comshould not be replaced.- Only strings like
@samor@exampleshould 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.
Wow. I found the answer myself guys.
Thanks for your help guys.