我在代码中使用了 python 正则表达式(re
模块),并注意到这些情况下的不同行为:
re.findall(r'\s*(?:[a-z]\))?[^.)]+', 'a) xyz. b) abc.') # non-capturing group
# results in ['a) xyz', ' b) abc']
和
re.findall(r'\s*(?<=[a-z]\))?[^.)]+', 'a) xyz. b) abc.') # lookbehind
# results in ['a', ' xyz', ' b', ' abc']
我需要得到的只是['xyz', 'abc']
. 为什么这些示例的行为不同以及如何获得所需的结果?