(?=p)的正向先行断言匹配p子模式前面的位置。换句话说,紧跟在p子模式之后的位置需要被满足。还有一个学名叫做forwardlookaheadassertion。上面的例子:'xxx_love_study_js.mp4'.replace(/(?=xxx)/g,'??')//??xxx_love_study_js.mp4(?!p)(?=p)表示倒过来,可以理解为(?=p)匹配位置以外的位置属于(?!p),也有学名negativelookaheadassertion。'xxx_love_study_js.mp4'.replace(/(?!xxx)/g,'??')//(?=xxx)输出??xxx_love_study_js.mp4//(?!xxx)输出x??x??x??_??l??o??v??e??_??s??t??u??d??y??_??js??.??m??p??4??(?<=p)匹配p子模式(注意(?=p)表示前一个的位置)。换句话说,有一个位置的前面部分需要满足p子模式。'xxx_love_study_js.mp4'.replace(/(?<=xxx)/g,'??')//xxx??_love_study_js.mp4(?
