Codice PHP:
var stringa="roby bell'S and mary'S ball and robert'S book";
stringa stringa.replace(/'S/g,"'s");