No this isn't a duplicate because all of the answers are different in other posts.

Does anyone know how to get replace something specific in a string? for example I'm trying to get rid of ALL commas that area together. Keep single commas but get rid of two only

For example:

w,h,o,,w,h,a,t,w,h,e,n,w,h,e,r,e,,t,h,e,n,,c,a,n,,b,u,t,,

I want to get rid of all instances where the double commas appear. Something kind of like:

```
var example = text.replace(/,,/g,' '); /*Space where ' ' is*/

```

If you understand what I mean. The next step is:

```
var text.replace(/,/g,'');

```

Thank you!

Code:

```
<html>
<head>
<script>
    function decrypt() {
        var input = document.getElementById("input").value;
        var x = input.split(",");
        var txtDisp="";
        for(var i = 0; i < x.length; i++) {
            if(x[i].type = "text") {
                crack = 94-(x[i]-32)+32;
                toTxt = String.fromCharCode(this, crack);
                txtDisp = txtDisp+","+toTxt;
                prep = txtDisp.replace(/,,/g,"");
            }
        document.getElementById("prompt").innerHTML=prep;   
        }
    }
</script>
</head>
<body>
<textarea rows='4' cols='100' style='resize:none;' id='input'></textarea>
<br>
<input type='button' value='execute' onclick='decrypt()' />
<p id='prompt'>
</p>
</body>
</html>

```

P.s. this code is already posted somewhere else where I asked a question.