后向断言得到了接受入ECMAscript规范 2018年至今,它只是在实现V8。因此,如果您正在开发仅适用于Chrome的环境(例如Electron)或Node,那么今天就可以开始使用lookbehinds!
console.log( ".99 €8.47".match(/(?<=$)d+(.d*)?/) // Matches "9.99");
负向后使用:
console.log( ".99 €8.47".match(/(?<!$)d+(?:.d*)/) // Matches "8.47");
平台支持:
- ✔V8
- ✔Google Chrome 62.0
- ✔Node.js 6.0 behind a flag and 9.0 without a flag
- ❌Mozilla Firefox (SpiderMonkey) is working on it
- ❌Microsoft was working on it for Chakra, but the next version of Edge will be built on Chromium and will thus support it
- ❌Apple Safari (Webkit) is working on it
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)