js string replace multiple code example
Example 1: replace many chracters js
var str = '#this #is__ __#a test###__';
str.replace(/#|_/g,'');
str.replace(/[#_]/g,'');
Example 2: multiple replace
var str = '[T] and [Z] but not [T] and [Z]';
var result = str.replace('T',' ').replace('Z','');
console.log(result);
Example 3: jquery replace multiple words
(".some-class").each(function() {
var text = $(this).html();
text = text.replace(/Phone: (\d{3}) (\d{3}) (\d{4})/, "Phone: $1.$2.$3");
$(this).html(text);
});