usa le regular expression. Non mi è chiaro però cosa vuoi sostituire.

Se solo il pipe

Codice PHP:
$testopreg_replace("/\\|([a-zA-Z0-9]{1,})/s","parolasostituita\$1",$test); 
Se il pipe con tutta la parola

Codice PHP:
$testopreg_replace("/\\|([a-zA-Z0-9]{1,})/s","parolasostituita",$test); 
se tutta la riga

Codice PHP:
$testopreg_replace("/\\|[a-zA-Z0-9]{1,}([^\n]{1,})/s","parolasostituita",$test);