codice:
<script>
var frase = "Si', cioe' e' cosi' che che potra' funzionare: ne' io ne' lui sapremo perche' ";

function normalizeAccents(text) {
    text = text.replace(/(ch)(e)'/gi, function($0, $1, $2) { return $1+"&"+$2+"acute;" }) 
    text = text.replace(/(\W)(n|s)(e)'/gi, function($0, $1, $2, $3) { return $1+$2+"&"+$3+"acute;"})
    text = text.replace(/(\W)(cio)(e)'/gi, function($0, $1, $2, $3) { return $1+$2+"&"+$3+"acute;"})
    text = text.replace(/(\w)'/gi, function($0, $1) { return "&"+$1+"grave;"})
    return(text);
}

document.write(normalizeAccents(frase));
document.write(normalizeAccents(frase.toUpperCase()));

</script>


</head>
Ciao



Keywords: sostituire sostituzione accenti regexp espressione regolare