Given the string bcacaca. The regex pattern b?(.a)*
should match on the whole string. However, a call to re.findall('b?(.a)*', 'bcacaca')
returns ['ca', '']
as a result. It seems to be only returning the result of matching on the individual groups. What's going on here?
My understanding of findall
is that it should return all nonoverlapping instances of the regex pattern. In this case it should return ['bcacaca', '']
.