$str = \'some text tag contents more text \';
My questions are:
How to retrieve content tag contents
which is between
For removal I ended up just using this:
$str = preg_replace('~~Usi', "", $str);
Using ~ instead of / for the delimiter solved errors being thrown because of the backslash in the end tag, which seemed to be an issue even with escaping. Eliminating > from the opening tag allows for attributes or other characters and still gets the tag and all of its contents.
This only works where nesting is not a concern.
The Usi
modifiers mean U = Ungreedy, s = include linebreak characters, i = case insensitive.