Remove everything outside of the brackets Regex

Also you can simply extract the string between brackets as below;

var myl = "okok{\"msg\":\"uc_okok\"}okok";
var mylExtractedStr = myl.match('\{.*\}')[0];

console.log(mylExtractedStr);

I presume okok.. is a string

var d = 'okok{"msg":"uc_okok"}'

console.log(d.slice(d.indexOf('{'), d.lastIndexOf('}') + 1))

s = 'okok{"msg":"uc_okok"}';
s = '{' + s.split('{')[1].split('}')[0] + '}';

console.log(s);

How about using the following;

myl.toString().replace(/.*?({.*}).*/, "$1")

It should work with multiple layers of brackets as well;

str = 'okok{"msg":"uc_okok"}';
console.log(str.replace(/.*?({.*}).*/, "$1"));

str = 'adgadga{"okok":{"msg":"uc_okok"}}adfagad';
console.log(str.replace(/.*?({.*}).*/, "$1"));