时间:2021-07-01 10:21:17 帮助过:7人阅读
var fun = function(str){
var preg = new RegExp("[\u4e00-\u9fa5]+","gi");
var preg2 = new RegExp("[^\u4e00-\u9fa5]","gi");
var count = 0;
for(var i=0;i<str.length;i++){
if(preg.test(str[i])){
count = count+2;
}else{
count = count+1;
}
}
return count;
}