Meaning that I simply want to strip the enclosing braces. I can match \"{ this kind of stuff }\" with:
\"{stuff}\".match(/{([^}]*)}/)[1]
Am
I agree with Lucero that Regexes are not made for that, but to answer your question:
The problem is that you match everything except }. But since the inside data you want to match contains itself a }, the content of the outer braces is not matched.
{
var foo = {
bar: 1
==> };
var foo2 = {
bar: 2
==> };
}
You can use this regex:
{([\S\s]*)}
To explain:
{ match opening {
( group
[\S\s] match everything, workaround for the missing s option in JS
* greedy, makes it match as much as possible
) end group
} match closing }