You can achieve the desired result either by splitting the string into each group +
and concatenating it with one space.
var str = 'I+am++a+++great++coder',
res = str.split(/\++/g).join(' ');
console.log(res);
Run code
or just replace each group +
with one space.
var str = 'I+am++a+++great++coder',
res = str.replace(/\++/g, ' ');
console.log(res);
Run code
source
to share