I have a particular syntax I use in strings which helps me retrieve and insert substrings. an example:
{{ variable ||| <div>example text</div>}}
Now I find myself having something like:
{{ variable1 |||
<div>some text</div>
<ul>
{{ variable2 |||<li>some other text<li/>}}
{{ variable3 |||<li>even more text<li/>}}
</ul>
}}
and obvously the regex I use for the first case does not match correctly.
the regex I usually use is:
/\B\{\{(.*?)\|\|\|(.*?)\}\}/
which in the second example matches:
{{ variable1 |||
<div>some text</div>
<ul>
{{ variable2 |||<li>some other text<li/>}}
which is not what I want.
I need a regex to match that particular syntax when it doesn't containt that particular syntax. I've tried many combinations similar to this:
\B\{\{(.*?)\|\|\|(.*(?!\{\{.*?\|\|\|.*?\}\}).*)\}\}
but can't work it out. It would be enough to get only
{{ variable2 |||<li>some other text<li/>}}
Because after the match I can delete that syntax so that recursively checking I can match everything.
The difficulty I have is that the string I parse is only in one line, so I can't use anythng like
^(?!example).*$
Am I right? What am I missing? I couldn't find a solution in other questions so I wrote this; sorry if this is a duplicate.
Thank you very much