Here is what I need to be able to do:
I need to match the following tag:
text sample
Regular expressions are not designed for tag manipulation.
If you have any form of nesting going on, it gets messy.
However, given the very simple example provided you could perhaps do this:
$MyString = preg_replace
( '/(?si)(.*?)<\/SPAN>/'
, '$1'
, $MyString
);
But this is flawed in many ways, and you are much better off using a tool designed for manipulating tags instead.
Have a look at DOMDocument->loadHTML() and related functions.