How do I include a str_replace in a preg_split regex?

0

The user types text in textarea (form html5)

Before writing to BD, I replace if I have a line break, changing '.br' or 'br' to '.'

$texto = str_replace(".<br>",". ",$texto);
$texto = str_replace("<br>",". ",$texto);
$grava-no-bd frase_1a_letra_maiusc($texto);

And I use this function to convert the typed text with merged caps into only the first letter of the sentences in upper case.

function frase_1a_letra_maiusc($string){
$frases=preg_split('/([.?!]+)/',$string,-1,PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
$corrigido='';
foreach ($frases as $key => $frase){
$corrigido .= ($key & 1) == 0 ? ucfirst(mb_strtolower(trim($frase))) : $frase.' ';
}
return trim($corrigido);
}

I ask:
Is it possible to include replace in the preg_split Regex?

Thank you in advance

    
asked by anonymous 03.08.2018 / 22:34

0 answers