So ersetzen Sie alle Zeichen in einem String -JavaScript
const string = "a, b, c, d, e, f";
string.replace(/,/g, '');
console.log(string) //a b c d e f
KadzielawaKonrad
const string = "a, b, c, d, e, f";
string.replace(/,/g, '');
console.log(string) //a b c d e f
var myStr = 'this,is,a,test';
var newStr = myStr.replace(/,/g, '-');
console.log( newStr ); // "this-is-a-test"
"x".replaceAll("x", "xyz");
// xyz
"x".replaceAll("", "xyz");
// xyzxxyz
"aA".replaceAll("a", "b", true);
// bb
"Hello???".replaceAll("?", "!");
// Hello!!!
let a = "How to search and replace a char in a string";
while (a.search(" ", ""))
{
a = a.replace(" ", "");
}
console.log(a);