KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm looking for a clean way to get a set (list, array, whatever) of words starting with # inside a given string. In C#, I would write var hashtags = input .Split (' ') .Where (s => s[0] == '#') .Select (s => s.Substring (1)) .Distinct (); What is comparatively elegant code to do this in Python? EDIT Sample input: "Hey guys! #stackoverflow really #rocks #rocks #announcement" Expected output: ["stackoverflow", "rocks", "announcement"]
Tags (comma-separated)
Save Edits
Cancel