php explode string排除html标签

I have a html content entry. I need to split by explode with ('.',$string). I need explode with '.' exclude html tags and use str_replace to insert new word but output include html tags. input :

$string = 'abc <a href="http://x.com">x.com</a> xyz.xxx <img src="y.com" /> zyx.yyy ';

output must :

abc <a href="http://x.com">x.(NEWWORD)com</a> xyz.(NEWWORD)xxx <img src="y.com" /> zyx.(NEWWORD)yyy
<?php
preg_match_all("/\/?(>\s?.*?\.)\w+/i",$string, $result);

foreach($result[1] as $row)
{
   $string = str_replace($row, $row."(NEWWORD)", $string);
}

echo $string;

//Good luck!