I am trying to find all occurances of a sub-string using regular expression. The sub-string is composed of three parts, starts with one or more 'A', followed by one or more 'N' and ended with one or more 'A'. Let a string 'AAANAANABNA' and if I parse the string I should get two sub-strings 'AAANAA' and 'AANA' as the output. So, I have tried the below code.
import regex as re
reg_a='A+N+A+'
s='AAANAANABNA'
sub_str=re.findall(reg_a,s,overlapped=True)
print(sub_str)
And, I am getting the below output,
['AAANAA', 'AANAA', 'ANAA', 'AANA', 'ANA']
But, I want the output as,
['AAANAA', 'AANA']
That is, the trailing A's of the first match should be the leading A's of the next match. How can I get that, any idea?