Ok, as it is WordPress problem and it sadly goes a little deeper, I need to remove each representation of parent div and its inside:
.*?<\/div>/s','',$content); ?>
My RegEx is a bit rusty, but I think this should work. Do note that, as others have said, RegEx is not properly equipped to handle some of the complexities of HTML.
In addition, this pattern won't find embedded div
elements with the class sometestclass
. You would need recursion for that.