var str = "Type=Cyber_TIME=*_5_K=1.7*"; var str2 = "Type=Cyber_TIME=3_5_K=1.70"; str2 = str = [...str].reduce((a,b) => a += b == "*" ? "" : b, "" ); console.log(str, str2);