<?
function verbete($txt, $sexo){
if( preg_match_all("#\[(.+?)\]#sie",$txt,$x) )
foreach($x[1] as $y){
$y2=explode("/",$y);
if($sexo=="F"){
$y3="[".$y."]";
$txt=str_replace($y3, $y2[1], $txt);
} elseif($sexo=="M") {
$y3="[".$y."]";
$txt=str_replace($y3, $y2[0], $txt);
}}
return $txt;
}

echo verbete("[sr/sra] nome vc � [m�dico/m�dica], ent�o vc � [um/uma] [Dr./Dra.]!", 'M');
?>