js正则中的贪婪和非贪婪模式问题总结

var b="abeeee:eeeee:eeeeeab";
console.log(b.match(/e+\:e+/g));//["eeee:eeeee"]贪婪模式,只显示第一个匹配到的
console.log(b.match(/e+?\:e+?/g));//["eeee:e", "eeee:e"]非贪婪模式,从前向后查询
console.log(b.match(/e+\:(?=e+)/g));//["eeee:", "eeeee:"]
console.log(b.match(/e+?\:(?=e+)/g));//["eeee:", "eeeee:"]
console.log(b.match(/(?<=e+)?\:(?=e+)/g));//[":", ":"]
console.log(b.match(/e+?\:(?!e+)/g));//null
console.log(b.match(/(?:e+)?\:(?:e+?)/g));//["eeee:e", "eeee:e"]
上一篇:HDMI转EDP芯片NCS8803简介


下一篇:非GUI模式运行Jmeter脚本