Text = "<a> text </a> <c> code </c>"
I want to remove <c> code </c>
statement in python
output = "<a> text </a>"
You can use re.sub
:
>>> import re
>>> text = "<a> text </a> <c> code </c>"
>>> new_text = re.sub(r'<c>.*?</c>', '', text)
>>> new_text
<a> text </a>