获取字符串长度(英文1个,中文2个)
//把双字节的字符替换成两个单字节的字符,并获取它的字符数
let str = '你好115s'
const len = str.replace(/[^\x00-\xff]/g, "00").length;
console.log(len)
标签:字符,常用,函数,len,js,获取,str
From: https://www.cnblogs.com/tn666/p/17381507.html
//把双字节的字符替换成两个单字节的字符,并获取它的字符数
let str = '你好115s'
const len = str.replace(/[^\x00-\xff]/g, "00").length;
console.log(len)
标签:字符,常用,函数,len,js,获取,str
From: https://www.cnblogs.com/tn666/p/17381507.html