javascript replace multiple characters code example
Example 1: js replace characters in a string
var str = "Original string!";
var str = str.replace("Original", "New");
Example 2: replace many chracters js
// You can use regex to do it in only one replace
// Using the or: |
var str = '#this #is__ __#a test###__';
str.replace(/#|_/g,''); // result: "this is a test"
// Or using the character class
str.replace(/[#_]/g,''); // result: "this is a test"
Example 3: multiple replace
var str = '[T] and [Z] but not [T] and [Z]';
var result = str.replace('T',' ').replace('Z','');
console.log(result);