Hashtag Extractor
Easypython
Given a social media post, extract all hashtags (words starting with #) using regex.
Approach: the pattern #\w+ matches a # immediately followed by one or more word characters.
Input: One line: a post, possibly containing hashtags.
Output: One line: every hashtag found, printed as a Python list, in order.
Example 1
Input
Loving #python and #coding today!
Output
['#python', '#coding']
- 1 <= length <= 1000
Hint 1
#\w+ matches a literal # followed by one or more word characters.
Hint 2
re.findall() collects every match into a list automatically.
#\w+ matches a literal # immediately followed by one or more word characters (letters, digits, underscore) — exactly a hashtag. re.findall() returns every such match in the text as a list, in the order they appear.