Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Remove Braces

Tags:

javascript

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?

like image 839
Sinal Avatar asked Nov 29 '11 07:11

Sinal


1 Answers

If you want to remove all occurrences of { and } whether or not they are matched pairs, you can do it like this:

var str = "{Street Name}, {City}, {Country}";
str = str.replace(/[{}]/g, "");
like image 81
Trott Avatar answered Oct 14 '22 04:10

Trott