I'd like to create a regex pattern that captures everything within a selfclosing html tag in a string, it is to be used in a php preg_replace that removes all selfclosing tags (that are normally not selfclosing, i.e. div, span etc.) from a html dom string.
Here's an example. In the string:
'<div id="someId><div class="someClass" /></div>'
I would like to get the match:
'<div class="someClass" />'
But I keep getting no match at all or this match:
'<div id="someId><div class="someClass" />'
I have tried the following regex patterns and various combinations of them
A simple regex pattern with the dot wildcard and excluding ">":
~<div.*?[^>].*?.*?/>~
A negative lookahead regex:
~<div(?!.*?>.*?)/>~
A negative lookbehind regex:
~<div.*?(?<!>).*?/>~
What am I missing?