$query = "Hello #world What's #up"
$newquery = "Hello, What's"
所以基本上我不想删除以#
开头的单词。
答案 0 :(得分:4)
试试这个:
$query = "Hello #world What's #up";
$newquery = preg_replace('/#[^\s]+/', '', $query);
echo $newquery;
答案 1 :(得分:2)
$newquery = preg_replace('/#[^\s]+/', '', $query);