-3

How can I replace multiple (++++++) signs with blank space?

Example: var string = "+++++++++++++++++";

R U
  • 92
  • 7

2 Answers2

1

var string = "+++++++++++++++++";
string = string.replace(/\+*/g, '');
console.log(string.length);
marvel308
  • 10,288
  • 1
  • 21
  • 32
  • Hello there, I tried your code, the snippet you presented seems to work just fine. I am indeed grateful for your help! – R U Aug 09 '17 at 11:57
0

const str = 'abc++++++def++++frberbf++fsvsf';
const newstr = str.replace(/(.)\+{2,}/g, ' ');
console.log(newstr);
kevguy
  • 4,328
  • 1
  • 24
  • 45