[英]How to get words starting with # and remove from string
$query = "Hello #world What's #up"
$newquery = "Hello, What's"
So basically I wan't to remove the words starting with #
. 所以基本上我不希望删除#
开头的单词。
Try this: 尝试这个:
$query = "Hello #world What's #up";
$newquery = preg_replace('/#[^\s]+/', '', $query);
echo $newquery;
使用preg_replace() 。
$newquery = preg_replace('/#[^\s]+/', '', $query);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.