You're so close! All you need to do is place the negated character class inside a capturing group and then store the contents of the first capturing group into an array.
/\@doc \{([^\}]+)\}/g
Here's an example:
> var str = '"/**' +
... '\n* @doc {' +
... '\n* description: "Invalid login without user", ' +
... '\n* request: "/v2/login", ' +
... '\n* response: "login-invalid-user.json"' +
... '\n* }' +
... '\n*/' +
... '\n some code goes here' +
... '\n some code goes here' +
... '\n some code goes here' +
... '\n/**' +
... '\n* @doc {' +
... '\n* description: "Invalid login without user", ' +
... '\n* request: "/v2/login", ' +
... '\n* response: "login-invalid-user.json"' +
... '\n* }' +
... '\n*/"';
undefined
> var re = /\@doc \{([^\}]+)\}/g;
undefined
> var m;
undefined
> while ((m = re.exec(str)) != null) {
... console.log(m[1]);
... }
* description: "Invalid login without user",
* request: "/v2/login",
* response: "login-invalid-user.json"
*
* description: "Invalid login without user",
* request: "/v2/login",
* response: "login-invalid-user.json"
The blank line between the two examples occurs because the regex also captures the newline character immediately following the {
bracket.
Update:
> var str = '"/**' +
... '\n* @doc {' +
... '\n* description: "Invalid login without user", ' +
... '\n* request: {url: "/v2/login1"}, ' + // <--- THIS HAS BEEN CHANGED
... '\n* response: "login-invalid-user.json"' +
... '\n* }' +
... '\n*/' +
... '\n some code goes here' +
... '\n some code goes here' +
... '\n some code goes here' +
... '/**' +
... '\n* @doc {' +
... '\n* description: "Invalid login without user", ' +
... '\n* request: {url: "/v2/login2"}, ' + // <--- THIS HAS BEEN CHANGED
... '\n* response: "login-invalid-user.json"' +
... '\n* }' +
... '\n*/"';
undefined
> var m;
undefined
> var re = /\@doc \{([\S\s]*?)\}(?=\n)/g;
undefined
> var m;
undefined
> while ((m = re.exec(str)) != null) {
... console.log(m[1]);
... }
* description: "Invalid login without user",
* request: {url: "/v2/login1"},
* response: "login-invalid-user.json"
*
* description: "Invalid login without user",
* request: {url: "/v2/login2"},
* response: "login-invalid-user.json"
*
undefined