原文 https://blog.csdn.net/qq_38111015/article/details/80416823
var s = 'CN_11223sgsg-dsg23.mtl' var matchReg = /(?<=CN_).*?(?=.mtl)/; s.match(matchReg)
正则前瞻(?=)和非捕获性分组(?:)区别
(?=)会作为匹配校验,但不会出现在匹配结果字符串里面
(?:)会作为匹配校验,并出现在匹配结果字符里面,
var data = 'windows 98 is ok'; data.match(/windows (?=\d+)/); // ["windows "] data.match(/windows (?:\d+)/); // ["windows 98"] data.match(/windows (\d+)/); // ["windows 98", "98"]
来源:https://www.cnblogs.com/liujinyu/p/11101394.html