Skip to content

Instantly share code, notes, and snippets.

@ajomathew
Created October 3, 2020 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajomathew/41bc8e44b451673da1b566afd9d89ba1 to your computer and use it in GitHub Desktop.
Save ajomathew/41bc8e44b451673da1b566afd9d89ba1 to your computer and use it in GitHub Desktop.
Java Script to filter Words from string starting with capital letter and add a # before it
var str = 'Why most Hacktoberfest PRs are from India'
var txt = ""
var hash = str.match(/\b([A-Z].*?)\b/g);
hash.reverse();
hash.pop();
for (i = 0 ; i < hash.length; i++){
txt = txt + ' #'+ hash[i]
}
txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment