Created
October 3, 2020 02:03
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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