I am trying to create a parser for this kind of texts:
{{texta1|texta2|texta3} {texta11|texta22}|{textb1|textb2} {textb11|textb22}}
I managed to get this regex ~(?<={).*?(?=})~U working to match the main content inside the first { and last }, but when I want to split {a|b|c}|{aa|bb|cc} with explode I am having problems since it wont split each {} into a separated array but will split every |, and if I split it using }|{, the output then gets kinda broken to try to parse it for later spinning cause a } and { will be missing on the output.
Does someone has a method to do this with regex or something like that that doesn’t require tons of code?
regex is not made for building parsers. there are a million posts on this site showing why. something like this is maybe more suited http://php.net/manual/en/function.strtok.php