javascript计算字符串长度 学习了:https://blog.csdn.net/u012934325/article/details/75214847 function getByteLen(val) { var len = 0; for (var i = 0; i < val.length; i++) { var a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { len += 2; } else { len += 1
/*** 计算字符串长度* 参数是要计算的字符串* 返回值当前字符串的长度*/function charactersLen (words) { let tempMapWordNum = {} let doubleByteTotal = 0 // 双字节 let chineseTotal = 0 // 汉字 let singleByteTotal = 0 // 单字节 let numTotal = 0 for (let i = 0; i < words.length; i++) { let c =
去除html标签: function del_html_tags(str) { var words = ''; words = str.replace(/<[^>]+>/g,""); return words; } 去除空格: function Trim(str,is_global) { var result; result = str.replace(/(^\s+)|(\s+$)/g,""); if(is_global.toLowerCase()