Basically using preg_replace function.
ideone - the result of your first example
ideone - the result of your second example
ideone - the 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 can be replaced by a single expression
$str = preg_replace(array('/\s{2,}/', '/[\n\r\t]/',), array(" ", " "), $str);
example - ideone
Or by joining 1, 2, and 3
$str = preg_replace(array('/Apelido/', '/:/', '/\s{2,}/', '/[\n\r\t]/',), array("",""," ", " "), $str);
example - ideone
The preg_replace function of php is a substitution function such as 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 characters from specific positions in a given text.