I\'m making a news and comment system at the moment, but I\'m stuck at one part for a while now. I want users to be able to refer to other players on the twitter style like
Here's an expression that'll match what you need, but won't capture email addresses:
$str = '@foo I loved the article, @SantaClaus, thanks for writing to my@email.com';
preg_match_all('/(^|[^a-z0-9_])(@[a-z0-9_]+)/i', $str, $matches);
//$matches[2][0] => @foo
///$matches[2][1] => @SantaClause
As you can see: my@email.com isn't captured, but the @foo and @SantaClaus strings are...