var jmz = {};
jmz.GetLength = function(str) {
return str.replace(/[\u0391-\uFFE5]/g,"aa").length; //先把中文替换成两个字节的英文,在计算长度
};
alert(jmz.GetLength('测试测试ceshiceshi'));
JS判断字符长度
最新推荐文章于 2022-04-19 14:05:54 发布
var jmz = {};
jmz.GetLength = function(str) {
return str.replace(/[\u0391-\uFFE5]/g,"aa").length; //先把中文替换成两个字节的英文,在计算长度
};
alert(jmz.GetLength('测试测试ceshiceshi'));