How to remove # from Twitter hashtags?

后端 未结 3 1136
渐次进展
渐次进展 2021-01-22 16:02

I want to strip off the # from twitter hash-tags, so:

Input: I love #winter and #ice-skating
Output: I love winter and ice-skating

I thought th

3条回答
  •  孤城傲影
    2021-01-22 16:16

    1. You need to have a sub-pattern to match the string without the pound sign
    2. Don't wrap 1 in the replacement string with curly braces
    $tweet = preg_replace('/#([^\s]*)/', '$1', $tweet);
    

提交回复
热议问题