Created
September 28, 2014 05:28
-
-
Save dmi3y/a3ba181f23f70cc90654 to your computer and use it in GitHub Desktop.
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
bukvy = new Set(); | |
word = 'world asdf a asdf asdf asdf asd fasdf sadf asdf asdf asdf as234234df asdf sadf asdf 5 alkjlkjkjsdf asdf asdf asd fasdfasd fasdf'; | |
out = []; | |
word.replace(/\d|\s/g, '').split('').forEach( | |
function(bukva) { | |
bukvy.add(bukva); | |
} | |
); | |
bukvy.forEach(function(bukva) { | |
var re = new RegExp(bukva, 'g'), | |
howmany = word.match(re).length; | |
out.push({bukva: bukva, howmany: howmany}); | |
}); | |
out.sort(function(a, b){ | |
return (a.bukva > b.bukva)? 1:-1; | |
}); | |
out.forEach(function(el){ | |
console.log(el.bukva, el.howmany); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment