Home > Web Front-end > JS Tutorial > body text

Discussion on the problem of character length limit in js_Basic knowledge

WBOY
Release: 2016-05-16 17:02:44
Original
1025 people have browsed it
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;
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template