[英]Ignore words less than or equal 3 javascript array
I'm building my own boorkmarklet for analyze the words in the current page, currently it's working good, but I would like filter the words and just show the words longer than 3 letters, I'm new with javascript but here is my code: 我正在建立我自己的boorkmarklet来分析当前页面中的单词,目前它工作正常,但我想过滤单词并只显示超过3个字母的单词,我是javascript的新手,但这里是我的代码:
var sWords = document.body.innerText.toLowerCase().trim().replace(/[,;.]/g,'').split(/[\s\/]+/g).sort();
// count duplicates
var iWordsCount = sWords.length;
// array of words to ignore
var ignore = ['and','the','to','a','of','for','as','i','with','it','is','on','that','this','can','in','be','has','if'];
ignore = (function(){
var o = {};
var iCount = ignore.length;
for (var i=0;i<iCount;i++){
o[ignore[i]] = true;
}
return o;
}());
thanks for the time ! 谢谢你的时间!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.