正则的基础知识
正则的基础知识
?=n
匹配任何其后紧接指定字符串 n 的字符串。
对其后紧跟 “all” 的 “is” 进行全局搜索: ( “is all”)
var str=“Is this all there is”;
var patt1=/is(?= all)/g;
str.match(“patt1”) //[“is”]
?!n
匹配任何其后没有紧接指定字符串 n 的字符串。
对其后没有紧跟 “all” 的 “is” 进行全局搜索: ( “is all”)
var str=“Is this all there is,”;
var patt1=/is(?! all)/g;
str.match(“patt1”) //[“is”]