// 只匹配出现在y后面的x 紧跟着y后面的x
console.log(/(?<=y)x/.exec('acyx'));
// 只匹配不是出现在y后面的x
console.log(/(?<!y)x/.exec('asax'))
// 只匹配出现在y前面的x
console.log(/x(?=y)/.exec('xyqqa'));
// 只匹配不是出现在y前面的x
console.log(/x(?!y)/.exec('zsxsary'));
JS正则匹配先行断言和后行断言
最新推荐文章于 2023-04-14 10:01:51 发布