【发布时间】:2011-04-18 11:58:56
【问题描述】:
我正在使用 preg_match_all 在 Twitter 搜索响应中搜索 HashTag 值。
除了搜索结果中没有任何哈希值外,它按我的预期工作。出于某种原因,我的 $tags 数组仍然有值,我不确定为什么。
是因为我的 RegEx 不正确,还是 preg_match_all 有问题?
谢谢
$tweet = "Microsoft Pivot got Runner-Up for Network Tech from The Wall Street Journal in 2010 Technology Innovation Awards http://bit.ly/9pCbTh";
private function getHashTags($tweet){
$tags = array();
preg_match_all("/(#\w+)/", $tweet, $tags);
return $tags;
}
结果:
Array ( [0] => Array ( ) [1] => Array ( ) )
预期结果:
Array();
【问题讨论】:
标签: php regex preg-match-all