原文 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"]

 

相关文章: