Skip to content

Instantly share code, notes, and snippets.

@aileron
Created May 8, 2012 01:45
Show Gist options
  • Save aileron/2631920 to your computer and use it in GitHub Desktop.
Save aileron/2631920 to your computer and use it in GitHub Desktop.
javascriptでなんとなく単語を抽出する
(function() {
var tags = [];
var _tags = {};
var words = document.documentElement.innerText.match(/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]+|[\u12449-\u12531\u12540;]+|[a-zA-Z0-9!]+|[a-zA-Z>0-9]+/g);
words.forEach(function(word) {
if (word.length <= 3 || _tags[word]) { return ; }
_tags[ word ] = 0;
tags.push( word ); });
delete _tags;
return tags;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment