Basically using preg_replace function.
ideone - result of your first example
ideone - result of your second example
ideone - result of your third example
//1- retira os termos indesejados Apelido e :
$patterns = array();
$patterns[0] = '/Apelido/';
$patterns[1] = '/:/';
$replacements = array();
$replacements[1] = '';
$replacements[0] = '';
$str = preg_replace($patterns, $replacements, $str);
//2- substitui quebras de linha (\n), "retornos de carro" (\r) ou tabulações (\t), por um espaço
$str = preg_replace('/[\n\r\t]/', ' ', $str);
//3- remove qualquer espaço em branco duplicado
$str = preg_replace('/\s(?=\s)/', '', $str);
//Retira espaço no ínicio e final
$str = trim($str);
expressions 2 and 3 may be replaced by a single expression
$str = preg_replace(array('/\s{2,}/', '/[\n\r\t]/',), array(" ", " "), $str);
example - ideone
Or joining 1, 2 and 3
$str = preg_replace(array('/Apelido/', '/:/', '/\s{2,}/', '/[\n\r\t]/',), array("",""," ", " "), $str);
example - ideone
The php preg_replace function is a substitution function like str_replace but with some differences, it supports regular expressions and other more powerful features. Preg_replace can be used to make substitutions or even to add specific position characters in a given text.