I want to replace all occurrences of ..
with . .
in a string. Basically, I don't want any .
character being succeeded by another .
character.
I've created this prototype function:
String.prototype.replaceAll = function (search, replacement) {
var target = this;
return target.replace(new RegExp(search, 'g'), replacement);
};
However, whatever input I try, it results in the complete string being replaced with .
characters, even though I've escaped the input and output string. What am I missing?
var description = 'hi there...how are you';
description = description.replaceAll('..', '. .');
description = description.replaceAll('\.\.', '\. \.');