Javascript Remove Braces

前端 未结 4 1894
臣服心动
臣服心动 2021-02-05 19:12

I have the string \"{Street Name}, {City}, {Country}\" and want to remove all braces. The result should be \"Street Name, City, County\". How do I do that?

4条回答
  •  萌比男神i
    2021-02-05 19:41

    The character class [{}] will find all curly braces

    var address = "{Street Name}, {City}, {Country}";
    address = address.replace( /[{}]/g, '' );
    console.log( address ) // Street Name, City, Country
    

提交回复
热议问题