I have text like:
"ababbabbba"
I want to extract the characters as a list between a. For the above text, I am expecting output like:
['aba', 'abba', 'abbba']
I have used:
re.split(r'a(.*?)a', data)[1:-1]
But it doesn't work.
CodePudding user response:
If you are willing to use findall instead of split this works.
import re
s = "ababbabbba"
print(re.findall(r'(?=(a[^a] a))',s))
prints:
['aba', 'abba', 'abbba']