I would like to see how I can obtain a regular expression to get the result in brackets without considering the sub brackets, I will explain with an example

```
let txt = F[aaa(0,0,0)] otra texto F[bbb(1,1,1)]
let regExp = /F\[([^\]]+)\]/g;
let matches = txt.match(regExp);
```

For which obtain an arrangement with the following:

```
F[aaa(0,0,0)],
F[bbb(1,1,1)]
```

I have the problem when I have the following:

```
let txt = F[aaa( F[ccc(2,2,2)],0,0)] otra texto F[bbb(1,1,1)]
```

For which to obtain an arrangement with the following:

```
F[aaa( F[ccc(2,2,2)] , F[bbb(1,1,1)]
```

and what I would like to obtain would be the following:

```
F[aaa( F[ccc(2,2,2)],0,0)] y F[bbb(1,1,1)]
```

In addition to this case I would like to consider all possible cases for example for 3 sub brackets:

```
let txt = F[aaa( F[ccc( F[ddd(3,3,3)],2,2)],0,0)] otra texto F[bbb(1,1,1)]
```

For what I would like to get

```
F[aaa( F[ccc( F[ddd(3,3,3)],2,2)],0,0)] y F[bbb(1,1,1)]
```