我使用正则表达式检测Twitter流中的@replies,使用正则表达式使用以下PHP代码。我怎么能结合这些正则表达式规则?
$text = preg_replace('!^@([A-Za-z0-9_]+)!', '<a href="http://twitter.com/$1" target="_blank">@$1</a>', $text);
$text = preg_replace('! @([A-Za-z0-9_]+)!', ' <a href="http://twitter.com/$1" target="_blank">@$1</a>', $text);
我怎样才能最好地结合这两个规则,而不会错误地标记[email protected]作为答复?
看看http://stackoverflow.com/questions/525635/regular-expression-match-start-or-whitespace – hop 2009-02-09 21:19:27
某人的相当自由与downvotes ... – 2009-02-09 21:41:40
我downvoted所有错误的答案,但不是这个问题... – hop 2009-02-10 10:24:13