I like to remove any empty html tag which is empty or containing spaces.
something like to get:
$string = \"text&
You will need to run the code multiple times in order to do this only with regular expressions.
the regex that does this is:
/<(?:(\w+)(?: [^>]*)?`> *<\/$1>)|(?:<\w+(?: [^>]*)?\/>)/g
But for example on your string you have to run it at least twice. Once it will remove the
and the second time will remove the remaining
.