Php 我如何忽略'';预赛

Php 我如何忽略'';预赛,php,regex,Php,Regex,嘿,伙计们,我试图用preg_match忽略周期,所以: $pos1 = preg_match( "/.*(#\S+)/", $currentStatus , $match ); $hash = $match[1]; 这将抓住twitter API中的2个标签,但让我们说他们已经#嗨 为什么不从结果中删除点: $hash = str_replace('.','', $match[1]); 为什么不从结果中删除点: $hash = str_replace('.','', $match[1]);

嘿,伙计们,我试图用preg_match忽略周期,所以:

$pos1 = preg_match( "/.*(#\S+)/", $currentStatus , $match );
$hash = $match[1];

这将抓住twitter API中的2个标签,但让我们说他们已经#嗨 为什么不从结果中删除点:

$hash = str_replace('.','', $match[1]);

为什么不从结果中删除点:

$hash = str_replace('.','', $match[1]);


在这种情况下,您需要定义一个白名单,例如:a-zA-Z0-9Ya对不起,我没有注意到…@Nelson解决了这个问题,不过我很感激!在这种情况下,您需要定义一个白名单,例如:a-zA-Z0-9Ya对不起,我没有注意到…@Nelson解决了这个问题,不过我很感激!
preg_match('/(#[a-zA-Z0-9]+)/', $currentStatus, $match);