Skip to content

Instantly share code, notes, and snippets.

@johwanghee
Created July 25, 2019 02:23
Show Gist options
  • Save johwanghee/9e3dea92f2418fe430ec5fcfa684a835 to your computer and use it in GitHub Desktop.
Save johwanghee/9e3dea92f2418fe430ec5fcfa684a835 to your computer and use it in GitHub Desktop.
def extract_hash_tags(s):
tags = set([i for i in s.split() if i.startswith("#")])
tags = set([re.sub(r"(\W+)$", "", j, flags=re.UNICODE) for j in tags]) # encoded
tags = set([re.sub(r"#+", "#", k) for k in tags]) # remove duplicate hash
return tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment