I have this code for my search: [code] <?php $q_words = array("test", "te"); $title = "test"; $word_ary = array(); foreach($q_words as $q_word) { if(strtolower($q_word)=="b" || empty($q_word) || in_array($q_word,$word_ary)) {continue;} $word_ary[] = $q_word; $title = eregi_replace(quotemeta(stripslashes($q_word)), "<b>\\0</b>", $title); } while(preg_match('#<b>(.*?)<b>(.*?)</b>(.*?)</b>#',$title)) { $title = preg_replace('#<b>(.*?)<b>(.*?)</b>(.*?)</b>#',"<b>\\1\\2\\3</b>",$title); } echo $title; ?> [/code] For the example $title I provided, that works perferctly, but if $title was "test test test", the output would be "<b>test</b> test <b>test</b>". So my question is, is there a way to remove nested <b > and </b >?