Codice PHP:
$str'_stringa_';
echo 
trim($str,'_');