我有一个包含哈希标签的字符串,我正在尝试将标签拉出我认为我非常接近但得到了一个具有相同结果的多维数组
$string = "this is #a string with #some sweet #hash tags";
preg_match_all('/(?!\b)(#\w+\b)/',$string,$matches);
print_r($matches);
产生
Array (
[0] => Array (
[0] => "#a"
[1] => "#some"
[2] => "#hash"
)
[1] => Array (
[0] => "#a"
[1] => "#some"
[2] => "#hash"
)
)
我只想要一个数组,每个单词都以哈希标记开头。