ES6: 字符串处理

UTF-16编码:str.codePointAt(index)String.fromCodePoint(codepoint);normalize()正则表达式新增u修饰符用来处理UTF-16编码的问题  &.$u

ES6: 字符串处理

UTF-16编码:

  • str.codePointAt(index)
  • String.fromCodePoint(codepoint);
  • normalize()

正则表达式

  • 新增u修饰符用来处理UTF-16编码的问题  /&.$/u
  • 新增pattern.flags 属性 // ‘ig’
  • 新增pattern.sticky 属性及’y’修饰符 // 只从lastIndex处匹配,如果和’g’一起存在则’g’被忽略
  • 复制正则表达式  // let pattern = new RegEX(old_pattern, ‘gi’)

字符串处理

  • str.includes(sub_string) // true or false
  • str.startsWith(sub_string)  // true or false
  • str.endsWith(sub_string) // true or false
  • str.repeat(times);  // str * times
  • 模板字面量
    • 支持多行字符串
    • 支持变量  // `hello ${name}`
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2018-07-24,如有侵权请联系 cloudcommunity@tencent 删除正则表达式string变量编码字符串

发布者:admin,转转请注明出处:http://www.yc00.com/web/1754944092a5218637.html

相关推荐

  • ES6: 字符串处理

    UTF-16编码:str.codePointAt(index)String.fromCodePoint(codepoint);normalize()正则表达式新增u修饰符用来处理UTF-16编码的问题  &.$u

    1月前
    200

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信