I need some help with regular expression in python. I have many files which, unfortunately, contains invaid xml: as below some 'img' tag is not closed.
<a href="a_url" class="url" target="_blank">
<img ng-src=" {{getImageUrl('homeHelp64.jpg')}}" alt="?" width="16" height="16">
Home
</a>
In Python what I would like to do is to find all such 'img' tags that are not closed and replace it with close tag like below ('/' before >):
<img ng-src=" {{getImageUrl('homeHelp64.jpg')}}" alt="?" width="16" height="16"/>
using the following pattern I can get all instances of img tag but i need to get only the ones that are not closed.
pattern = '(img.*?)>'
will appreciate your help in defining the pattern and how to replace the 'img' and close the xml tag at the end.