Home  >  Article  >  Web Front-end  >  Discussion on the problem of character length limit in js_Basic knowledge

Discussion on the problem of character length limit in js_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:02:44984browse
Copy code The code is as follows:

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;iif(preg.test(str[i])){
count = count 2;
}else{
count = count 1;
}
}
return count;
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn