更新时间:2022-11-12 09:50:10
前瞻((?=
部分)不消耗任何输入.它是一个零宽度断言(边界检查和lookbehinds也是如此).
A lookahead (that (?=
part) does not consume any input. It is a zero-width assertion (as are boundary checks and lookbehinds).
您想要在这里进行常规匹配,以消耗 cow
部分.要捕获两者之间的部分,请使用捕获组(只需将要捕获的模式部分放在括号内):
You want a regular match here, to consume the cow
portion. To capture the portion in between, you use a capturing group (just put the portion of pattern you want to capture inside parenthesis):
cow(.*)milk
根本不需要前瞻.