RegExp断言
先行断言
lookahead assertion
:x
在y
之前才匹配,格式为/x(?=y)/
negative lookahead assertion
:只有x
不在y
之前才匹配,格式为/x(?!y)/
1 | let str = 'now is 02:11:44' |
后行断言
lookbehind assertion
:x
只有在y
后面才匹配,格式为/(?<=y)x/
negative lookbehind assertion
:只有x
不在y
后面才匹配,格式为/(?<!y)x/
1 | let str = 'now is 02:11:44' |