I was hoping to use regular expressions in JS to extract bounded substrings. Specifically, substrings that are bounded by %{ }. For the simple case it is easy enough with %{.*?}.
However, I was hoping to be able to ignore nested braces {} and strings "" or ''. I know how to get those independently similar to the above regular expression, but I don't know how to combine things meaningfully.
I'd like the hard_string to output [ "{{friends}} and foes", "cause problems with my '}'s" ]
let easy_string = "Hello %{world}, I am here to %{cause problems}"
let hard_string = "Hello %{{{friends}} and foes}, I am here to %{cause problems with my '}'s} and {{mustaches}}"
console.log('easy string = ',easy_string.match(/%{.*?}/g).map(s=>s.slice(2,-1)))
console.log('hard string = ',hard_string.match(/%{.*?}/g).map(s=>s.slice(2,-1)))