Question: i want to make this:

```
i went to the [open shops], but the [open shops] were closed

```

look like this:

```
i went to the markets, but the markets were closed

```

with javascript replace

im not very good with regex and the square brackets need delimited im sure

Answer: 
Try this:

```
"i went to the [open shops], but the [open shops] were closed".replace(/\[open shops\]/g, 'markets');

```

The tricky part is the the need to escape the brackets and add the global match to replace each matching instance. For more info: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace>
If you don't want to use regex. You could use something like.

```
    var a = "i went to the [open shops], but the [open shops] were closed";
    var replacement = "KAPOW!";

    while(a.contains("[") && a.contains("]"))
    {
        var left = a.indexOf("[");
        var right = a.indexOf("]");

        a = a.substring(0,left) + replacement + a.substring(right+ 1);
    }

    console.log(a);

```