yyman001 / blog

日常疑问记录解答
5 stars 0 forks source link

JS判断字符串长度(英文占1个字符,中文汉字占2个字符) #14

Open yyman001 opened 7 years ago

yyman001 commented 7 years ago
checkTextLength:function (string) {
  return string.replace(/[^\x00-\xff]/g,"aa").length;
 //return str.replace(/[\u0391-\uFFE5]/g,"aa").length;
},

http://blog.csdn.net/testcs_dn/article/details/21412303