I have this string
{ prop1: 'val1', prop2:{ prop3: 'val3' , messages: {something:'val'} messages: { something:'val2', x : {x : 1, y : 5} } } , prop4: 'val4' }
how can I find all instances of messages: { ... }
in javascript with xregexp (or another solution)
This /messages: (\{(?>[^{}]+|(?1))*\})/g
is working in php, but not in javascript
Also couldn't figure it out by using xregexp
recursion http://xregexp.com/api/#matchRecursive
Tried https://repl.it/@RezaRahmati/xregexp
XRegExp.matchRecursive(str, 'messages: {', '}', 'gi')
but getting Unbalanced delimiter found in string
error
Update
as @vs97 and @barmar comment, I tried messages: (\{.+\})
and works on multiline, still issue when it's single line