var arr = ["pippo%12pluto%_prova", "ori%_aa"];
for (i=0; i<arr.length; i++) {
console.log( arr[i] + ' => ' + arr[i].replace(/(^|[^'])'(?!')/g, "$1''") );
}
var arr = ["abc'def", "abc''de'f"];
for (i=0; i<arr.length; i++) {
console.log( arr[i] + ' => ' + arr[i].replace(/(^|[^'])'(?!')/g, "$1''") );
}