Challenge: Extract Hashtags from Social Media Text
Instructions:
To further develop your skills with advanced regular expressions, your task is to create a function that extracts all hashtags from a social media post.
A hashtag is any word that starts with the # character, followed by one or more alphanumeric characters or underscores, and is not immediately preceded by another word character.
Your function should:
- Handle hashtags at the beginning or end of the text;
- Correctly extract hashtags surrounded by punctuation or whitespace;
- Return all hashtags exactly as they appear in the text, including the
#symbol.
Example:
Given the input:
"Excited for the #Python3_12 release! #coding #AI #100DaysOfCode"
you should return:
['#Python3_12', '#coding', '#AI', '#100DaysOfCode']
Use regular expressions to solve this challenge and pay special attention to edge cases.
Swipe to start coding
Create a function that extracts all hashtags from a social media post. A hashtag is any word that begins with the # character, followed by one or more alphanumeric characters or underscores, and is not immediately preceded by another word character. Your function must correctly identify hashtags at the beginning or end of the text, as well as those surrounded by punctuation or whitespace. Return all hashtags exactly as they appear in the text, including the # symbol.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Awesome!
Completion rate improved to 6.67
Challenge: Extract Hashtags from Social Media Text
Veeg om het menu te tonen
Instructions:
To further develop your skills with advanced regular expressions, your task is to create a function that extracts all hashtags from a social media post.
A hashtag is any word that starts with the # character, followed by one or more alphanumeric characters or underscores, and is not immediately preceded by another word character.
Your function should:
- Handle hashtags at the beginning or end of the text;
- Correctly extract hashtags surrounded by punctuation or whitespace;
- Return all hashtags exactly as they appear in the text, including the
#symbol.
Example:
Given the input:
"Excited for the #Python3_12 release! #coding #AI #100DaysOfCode"
you should return:
['#Python3_12', '#coding', '#AI', '#100DaysOfCode']
Use regular expressions to solve this challenge and pay special attention to edge cases.
Swipe to start coding
Create a function that extracts all hashtags from a social media post. A hashtag is any word that begins with the # character, followed by one or more alphanumeric characters or underscores, and is not immediately preceded by another word character. Your function must correctly identify hashtags at the beginning or end of the text, as well as those surrounded by punctuation or whitespace. Return all hashtags exactly as they appear in the text, including the # symbol.
Oplossing
Bedankt voor je feedback!
single