#238 · Regular expressions · Beginner · 35 XP · about 6 min
A social media post can mark its topics with hashtags such as #python. Write find_hashtags(post) that returns the topics a post is tagged with, as a list of lowercase strings without the #.
A hashtag is a # followed by one or more letters, digits or underscores. The tag ends at the first character that is not one of those, so in "#rain!" the tag is "rain". A # with none of those characters right after it is not a hashtag. A # can start a tag anywhere, even right after a letter or digit, so "#a#b" holds two tags, "a" and "b".
List each tag once, in the order it first appears. Tags that differ only in case count as the same tag.
find_hashtags('Loving #Python and #python3! #100DaysOfCode #python') # returns ['python', 'python3', '100daysofcode'] find_hashtags('#Sale #SALE #sale today only') # returns ['sale'] find_hashtags('No tags here, # not even this') # returns []
Posts use only ASCII characters: English letters, digits, spaces and punctuation.
First solves only, ranked by stars and then time.