I need to split text by pipe that is not in brackets. Here is the sample text
I {need|want|{ask|prefer}} you to {help {Jason|Maria|Santa|{Lucia|Raul}'s father}|go to school}
I have found this /\|(?![^{]*})/g
here: regex, extract string NOT between two brackets
now when i want to split this part of string by pipe
help {Jason|Maria|Santa|{Lucia|Raul}'s father}|go to school
it also selects pipes between Jason, Maria, Santa because there is an opening bracket after them. How to change regex to match only pipe if it's not in any of the brackets.
test strings:
help {Jason|Maria|Santa|{Lucia|Raul}'s father}|go to school
should return
help {Jason|Maria|Santa|{Lucia|Raul}'s father}
go to school
.
Jason|Maria|Santa|{Lucia|Raul}'s father
should return
Jason
Maria
Santa
{Lucia|Raul}'s father