统计包含中文的字符长度,一个汉字算两个字符

String.prototype.len=function(){return this.replace(/[^\x00-\xff]/g,"aa").length;}


只统计中文

var pattern_chin = /[\u4e00-\u9fa5]/g;

var count_chin = tempStr.match(pattern_chin).length;