Question: I am facing the issue in getting the substring using the regex.

I want to fetch all the substring enclosed inside the braces.

ex. abc {{{data1} xyz {data2}}`

I am using the `\\{.*?\\}` as a regex and getting the output as `{{{data1} {data2}`

I want the regex to give me output as `{data1} {data2}` (No extra braces in start of data1)

How can I achieve this? Is there any regex I can put?

Answer: 
You may use `({[^{}]+})` to find out the matches. This will match anything between the braces, which are not `{}`.

```js
const str = 'abc {{{data1} xyz {data2}}';
console.log(str.match(/{[^{}]+}/g));
```
Match `{`, followed by word characters, followed by `}`:

```js
const str = 'abc {{{data1} xyz {data2}}';
console.log(str.match(/\{\w+\}/g));
```