This will work but I don\'t think it\'s the cleanest way...
$string = \"AnyText - StringA - UnwantedText - StringB - AnyText\"
$array_beg = explode(\"StringA\", $string);
$array_end = explode(\"StringB\", $string);
$newstring = $array_beg[0].\"StringA\".\"StringB\".$array_end[1];
echo $newstring;