字符串方法

1、正确获取字符串长度(包括码点大于0xFFFF的Unicode字符)

function codePointLength(text) {
  var result = text.match(/[sS]/gu);
  return result ? result.length : 0;
}

  

原文地址:https://www.cnblogs.com/huangqiming/p/6281693.html