考虑以下字符串:
我在RegexBuddy中得到的结果如下(请注意中间的一个匹配不正确,应该匹配
ab(cd.xz) e(ab(fg).xz)) ab(hi.xz)
我希望能够匹配以ab(开始并以z结尾的所有子字符串。因此,我编写了以下正则表达式:
(?<=a.*?\().*?z
根据RegexBuddy的提示,这应该尝试执行以下操作:
Assert that the regex below can be matched, with the match ending at this position (positive lookbehind) «(?<=a.*?\()»
Match the character “a” literally «a»
Match any single character that is not a line break character «.*?»
Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Match the character “(” literally «\(»
Match any single character that is not a line break character «.*?»
Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Match the character “z” literally «z»
我在RegexBuddy中得到的结果如下(请注意中间的一个匹配不正确,应该匹配
fg).xz
)。我做错了什么?