Removing Javascript Clips

I have the line "{Street Name}, {City}, {Country}" and you want to remove all curly braces. The result should be "Street Name, City, County." How to do it?

+6
source share
4 answers

If you want to remove all occurrences of { and } regardless of whether they match pairs, you can do this as follows:

 var str = "{Street Name}, {City}, {Country}"; str = str.replace(/[{}]/g, ""); 
+27
source

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 
0
source
 str = str.replace(/[{}]/g,""); 
0
source

Use this simple javascript code in your corresponding function to remove curly braces:

  var str = '{Street Name}, {City}, {Country}'; str = str.replace(/{/g, '').replace(/}/g, ''); 
0
source

Source: https://habr.com/ru/post/902619/


All Articles