I\'m implementing some kind of parser and I need to locate and deserialize json object embedded into other semi-structured data. I used regexp:
As others have suggested, a full-blown JSON parser is probably the way to go. If you want to match the key-value pairs in the simple examples that you have above, you could use:
(?<=\{)\s*[^{]*?(?=[\},])
For the input string
{title:'Title', {data:'Data', {foo: 'Bar'}}}
This matches:
1. title:'Title'
2. data:'Data'
3. foo: 'Bar'