The code must check if a given string is found between the tags. But as you can see below, the span tag is built with many other attributes and other css classes that change, it is rather unpredictable.
$body = '<p>Lorem ipsum, lorem ipsum. Lorem ipsum, lorem ipsum. Lorem ipsum, lorem ipsum. Lorem ipsum, lorem ipsum. Lorem ipsum, lorem ipsum.</p><p><span id="subject-47" class="enco-subject enco-subject-post-1" data-id="47">Semencic credits his early familiarity with the breed to his own travels to South Africa<span class="enco-comment-count">4</span></span> , but especially to his frequent correspondence with the head of the first South African Boerboel club, one Mr. Kobus Rust. <strong>The Boerboel Breeders Association was established in 1983</strong> in the Senekal district of the Free State with the sole objective of ennobling and promoting the Boerboel as a unique South African dog breed.</p>';
$body2 = 'We all love South Africa because of its <span class="enco-highlight">beautiful scenery</span>. It is not the cheapest country but blah blah blah.';
$string_to_check = 'South Africa';
So, here is what should be returned:
body = the string exists within span.enco-subject tag (but it's a complicated tag..)
body2 = the string does not exists within span.enco-subject