In JavaScript, Strings are immutable. Thus, when changing a string, a new string object will be created with the modification.
In your case, replace replaced the characters, but returns a new line. You need to store this in a variable in order to use it.
For instance,
var temp = '2015โ09โ01T16:00:00.000Z'; temp = temp.replace(/โ/g,'--');
Note The line that you indicated in the question when copying, I realized that this is a different character , but similar to โ and this is not the same as a hyphen ( - ). The character codes for these characters are as follows
console.log('โ'.charCodeAt(0)); // 8211: en dash console.log('-'.charCodeAt(0)); // 45: hyphen
source share