Go back to Challenges list
Find the #hashtags
In this challenge you will receive a string with a user comment in your social network and you will need to retrieve the valid #hashtags that the user inserted during the comment.
The rules to detect a valid #hashtags are:
- Hashtags are alphanumeric strings ([a-zA-Z0-9]) prefixed with the hash symbol "#" (e.g. "#keyword" is a valid hashtag and #2Words!? counts as "2Words" only)
- Hashtags cannot be in the middle of a words or characters (e.g. "some#word" and ".?!#word" are invalid)
- Hash symbols ("#") alone are not valid
- If a word is preceded by more than one hash symbol, only one hashtag counts (e.g. "###keyword" counts only as "keyword")
- Since hashtags are only alphanumeric [a-zA-Z0-9] in case (e.g. "###keyword" counts only as "keyword")
The rules to detect a valid #hashtags are:
- Hashtags are alphanumeric strings ([a-zA-Z0-9]) prefixed with the hash symbol "#" (e.g. "#keyword" is a valid hashtag and #2Words!? counts as "2Words" only)
- Hashtags cannot be in the middle of a words or characters (e.g. "some#word" and ".?!#word" are invalid)
- Hash symbols ("#") alone are not valid
- If a word is preceded by more than one hash symbol, only one hashtag counts (e.g. "###keyword" counts only as "keyword")
- Since hashtags are only alphanumeric [a-zA-Z0-9] in case (e.g. "###keyword" counts only as "keyword")
Input Format
Each input will be a stringOutput Format
The output should be a string with the hashtags in order separated by commas without spacesSample Input
Woow awesome #pic dude #lmao #omgSample Output
pic,lmao,omgMemory Limit
512M