var str = "Type=Cyber_TIME=*_5_K=1.7*"; var str2 = "Type=Cyber_TIME=3_5_K=1.70"; str2 = str = [...str].filter(a => a != "*").join(""); console.log(str, str2);