I have an input string like this:

```
ABCDEFG[HIJKLMN]OPQRSTUVWXYZ

```

How can I replace each character in the string between the `[]` with an `X` (resulting in the same number of `X`s as there were characters)?

For example, with the input above, I would like an output of:

```
ABCDEFG[XXXXXXX]OPQRSTUVWXYZ

```

---

I am using JavaScript's RegEx for this and would prefer if answers could be an implementation that does this using JavaScript's RegEx Replace function.

---

I am new to RegEx so please explain what you do and (if possible) link articles to where I can get further help.