Remove everything outside of the brackets Regex

  • A+
Category:Languages

This is what I am trying to remove strings from:

okok{"msg":"uc_okok"} 

and the results should be:

{"msg":"uc_okok"} 

I have tried using regex

var news = myl.toString().replace(/ /{(.*""?)/}/g); 

but its not working? Any ideas?

 


How about;

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

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: