I use python regular expressions (re
module) in my code and noticed different behaviour in theese cases:
re.findall(r'\s*(?:[a-z]\))?[^.)]+', 'a) xyz. b) abc.') # non-capturing group
# results in ['a) xyz', ' b) abc']
and
re.findall(r'\s*(?<=[a-z]\))?[^.)]+', 'a) xyz. b) abc.') # lookbehind
# results in ['a', ' xyz', ' b', ' abc']
What I need to get is just ['xyz', 'abc']
. Why are the examples behave differently and how t get the desired result?
a)
in text, then match the whole text). – Decarbonate