ErgExp-lookbehind assert(后行断言)

//先行断言:先遇到一个条件,判断后面的条件是否知足
let test = 'hello world'
console.log(test.match(/hello(?=\sworld)/))

//后行断言
//判断world的前面是否是hello
console.log(test.match(/(?<=hello\s)world/))
//匹配world前面不是hello的
console.log(test.match(/(?<!hells\s)world/))
相关文章
相关标签/搜索