Podrías hacer algo así, pasa por el área de aportes para que veas un tema que te puede ayudar a desenvolverte con expresiones regulares.
Código PHP:
Ver original<?php
$str_to_edit = '<span class="underline"> It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like
Aldus PageMaker including versions of Lorem Ipsum.</span>Lorem Ipsum is simply dummy text of the
printing and typesetting industry.<br /></span><span class="italic">Lorem Ipsum is simply dummy
text of the printing and typesetting industry.<br /></span><span class="underline">Lorem Ipsum is
simply dummy text of the printing and typesetting industry.</span><br /><br />
<span class="italic bold">Lorem Ipsum is simply dummy text of the printing and typesetting
industry.<br /></span><span class="bold italic">Lorem Ipsum is simply dummy text of the printing
and typesetting industry.<br /></span><span class="underline italic bold">Lorem Ipsum is simply
dummy text of the printing and typesetting industry.</span>';
$find = array('<span class="underline">', '</span>'); $replace = array('<b><i>', '</i></i>'); $str = preg_replace('/<span.*?>(.+?)<\/span>/is', '<b><i>$1</i></b>', $str_to_edit); echo $str;