Skip to content

Instantly share code, notes, and snippets.

@shaselton
Last active April 2, 2016 18:28
Show Gist options
  • Save shaselton/aeb5ea3805519c973068ac7751500b45 to your computer and use it in GitHub Desktop.
Save shaselton/aeb5ea3805519c973068ac7751500b45 to your computer and use it in GitHub Desktop.
You start working for a fancy new startup hoping to revolutionize social networking! GASP! They had this great idea that users should be able to specify relevant keywords to their posts using an ingenious idea by prefixing those keywords with the pound sign (#). Your job is to extract those keywords so that they can be used later on for whatever…
def parse_hash_tags(str)
str.split(' ').select{ |word| /^#+([a-zA-Z])/.match(word) }.map{ |hash_tag| hash_tag.gsub(/^#+/, '') }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment