This is what I have so far:
\s#([^ ]*)
Example : http://regexr.com?2te3d
It works pretty well except hashtags at the beginning of strings don'开发者_运维问答t get picked up by my RegEx.
How should I modify it to pick these ones up as well? The \b command doesn't seem to work the same way as it does with normal words.
If it is just about the beginning of the string, you could do:
(^|\s)#([^ ]*)
Try this regex: \B#([^ ]+)
It matches all hashtags except the one in the URL which i guess shouldn't be matched
Given this input: #first #second # #third #weird#tag #with-minus #
This: /(^|\s)#([^\s]+)/g
will skip empty #'s and will only match:
- #first
- #second
- #third
- #weird#tag
- #with-minus
精彩评论