I have a String Alltext that contains text across multiple lines
aaaaa
D0
aaaaa
text0...........
aaaaa
D1
aaaaa
text 1 ..........
aaaaa
D2
aaaaa
text 2
I want to keep just the text part i.e. text0...., text1 , text2.... and remove the indicators
aaaaa
D0
aaaaa,
aaaaa
D1
aaaaa
and so on.These indicate next text segment. I tried this regular expression
re.sub("[a]* \sD[0-9]*\\s[a] * ", " ",Alltext)
but this just removes D0, D1 and not the aaaa The output I get
aaaaa
aaaaa
text0
aaaaa
aaaaa
text1
How can I remove these aaaaa