:eek: - because tables can be nested to an arbitrary depth, that is something that just can't be done in a single regexp. (Okay, I know: with backreferences the things aren't pure regular expressions anyway, but I don't think they'll save us here because they can't count.)
A loop is needed.
while(preg_match(/*regexp to find a table*/,$html)){
$html=preg_replace(/*regexp to find an unnested table*/,'',$html);
}
My first attempt at the second regexp would be
'#<table((?🙁?!<table).)*)</table>#is'
but I have this weird urge to suggest
'#<table[<](?🙁?!</?table)<[<])*</table>#is'
as being faster (assuming it even works! 😉)