How to match a pound (#) symbol in a regex in php (for hashtags)

后端 未结 5 1196
孤独总比滥情好
孤独总比滥情好 2021-01-17 17:02

Very simple, I need to match the # symbol using a regex. I\'m working on a hashtag detector.

I\'ve tried searching in google and in stack overflow. One

5条回答
  •  既然无缘
    2021-01-17 17:29

    You could use the following regex: /\#(\w+)/ to match a hashtag with just the hashtag word, or: /\#\w+/ will match the entire hashtag including the hash.

提交回复
热议问题