Want to remove curly bracers from a string

javascript, json

Solution

Javascript strings are immutable. When you call `blah2.replace`, you are not replacing something inside `blah2`, you are creating a new string. What you probably want is:

blah2 = blah2.replace(/[{}]/g, '');

Problem

I did a search through the site, but it's still not working. ``` var blah2 = JSON.stringify({foo: 123, bar: <x><y></y></x>, baz: 123}); ``` this is what I tried: ``` blah2.replace(/[{}]/g, ""); ``` this is what it the string comes out to: ``` got "{\"baz\":123,\"foo\":123}" ``` (i know this is probably a newb question, but this is my first time working with javascript and i just don't know what i'm missing)

Original source

Related problems