I have some text, in a similar pattern to:
new{test}anotherone{test{nest}}new1{test1}new2{test2}
I'm new to Regex, and trying to create a pattern which matches groups such that for each match: Group 1: new Group 2: test
I have this working with ([\S][a-z#-()->]+)\{([^?+]*?)\}
using JavaScript
However, I want to ignore the block with the nesting, such that the anotherone{test{nest}}
is ignored from the matching. Here's my attempt on Regex101
Thanks in advance!
Update: The string might also have nested inside the nested part, e.g.
new{test}ignore_this{test1{test1}{test2{test2}}new{test}new{test}
Such that it should only match: Group1: new / Group2: test
\b(?<![{}])(\w+)\{([^{}]*)\}
, see demo. – Wiktor Stribiżew([^\s{}]+)\{([^{}]*)}(?!})
regex101.com/r/CSrZWq/1 – The fourth bird