Is it possible to remove all the blank <a>
tags in some HTML code using regex?
For example,
<a href="this-goes-somewhere.com" rel="external"></a>
<a href="go-to-that-page.html"></a>
<a href="this-should-stay.html">This Should Stay</a>
<a href="this-should-stay.html"><img src="kitten.jpg"/></a>
In this case, the regex should remove the first two links. I used <a(.*?)></a>
to achieve this but it matches all four links.
Any help would be appreciated.
I thought ?
was meant to stop at minimum possible number of characters.
UPDATE: The HTML will not be invalid, I am generating it myself. Using Regex will be much easier in this particular case, in my opinion.