I have a string, in which I am doing replace operation with the help of regex.It is done, in order to replace the particular character in the string, if that exists and to retain others.
var text = "abcdef";
var text = ((text.replace(/a/g, '1')) + (text.replace(/b/g, '2')) + (text.replace(/c/g, '3')));
Expected Output: 123def
But I am getting the output like this: 1bcdefa2cdefab3def