I have a text like
It's a beatiful {day|morning|{month|year}} and I {watch {a serie| a movie}|play games}
I want to get
day|morning|{month|year}
and
watch {a serie| a movie}|play games
from this text.
Currently I have a regex using /\{(.+?)\}/g
but it's not working when there are brackets inside brackets. This is an example from what I currently have: https://www.regextester.com/?fam=105404
As you can see, {day|morning|{month|year}}
is not selecting completely because there are nested braces. How can I fix this?