showing results for - "javascript replace char if not present another character"
Máximo
23 Jan 2021
1var arr = ["pippo%12pluto%_prova", "ori%_aa"];
2
3for (i=0; i<arr.length; i++) {
4   console.log( arr[i] + ' => ' + arr[i].replace(/(^|[^'])'(?!')/g, "$1''") );
5}
Angeline
20 Apr 2019
1var arr = ["abc'def", "abc''de'f"];
2
3for (i=0; i<arr.length; i++) {
4   console.log( arr[i] + ' => ' + arr[i].replace(/(^|[^'])'(?!')/g, "$1''") );
5}