I am learning regex with experimenting on HTML files, I have a regex problem,
My text is :
text='12<a>1<a>2</a>3</a>13<a>4<a>5</a>6</a>14'
The expression
<a><a></a></a> is nested
I want to write a regex that can handle nested expression, for example, my output for the above text should be
Output : 121314
I use the regex,
re.sub('<a>(.+?)</a>', '', text, flags=re.DOTALL)
I get an output:
'123</a>136</a>14'
This is because the regex is unable to handle nested expression.