1

I have an example statement:

"function(){var x=0;if(true){var y=0;}}"

I have tried many expressions but they only return the "{var y=0;}"

I want to extract the following result:

["{var x=0;if(true){var y=0;}}","{var y=0;}"]

What is the best possible regex for this?

I only use JavaScript so lookbehinds are not possible.

Richeve Bebedor
  • 2,138
  • 4
  • 26
  • 40

1 Answers1

0

I just tested the following with a JS Regex tester and it seems to work:

This Regex works only on 2 nested curly brackets, may not work with 3 or more but the Regex can be adjusted accordingly.

Kind regards,

    Yaron Shahrabani.
Yaron
  • 1,199
  • 1
  • 15
  • 35