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/))
相關文章
相關標籤/搜索