Reputation: 545
I have a regex to remove empty tags HTML, like <p></p>
or <span></span>
, but inside them I can have images and I want to ignore the tag <img>
. My regex:
(<(?!\/)[^>]+>)+(<\/[^>]+>)+
My uses cases:
I want to ignore the last line, because I have an image inside the tag.
Check the live editor: https://regex101.com/r/81M8VR/1
Upvotes: 0
Views: 370
Reputation: 302
The following seems to work:
(<(?!\/)((?!img)[^>])+>)+(<\/[^>]+>)+
https://regex101.com/r/A0N1rL/1
Upvotes: 1