There are some problems with the answers presented here.
{tag.strip ("#") for the tag in .split () tags, if tag.startswith ("#")}
[i [1:] for i in the string .split () if i.startswith ("#")]
wont work if you have hashtag like '# one # two #'
2 re.compile(r"#(\w+)") does not work for many Unicode languages (even using re.UNICODE)
I saw more ways to extract the hashtag, but found that they did not answer all cases
so I wrote a little python code to handle most cases. he works for me.
def get_hashtagslist(string): ret = [] s='' hashtag = False for char in string: if char=='#': hashtag = True if s: ret.append(s) s='' continue
source share