The following statement in JavaScript works as expected:
var s1 = s2.replace(/ /gi, '_'); //replace all spaces by the character _
However, to replace all occurrences of the character . by the character _, I have:
var s1 = s2.replace(/./gi, '_');
But the result is a string entirely filled with the character _
Why and how to replace . by _ using JavaScript?