JSFiddle - React, Tailwind, and code Playground
JavaScript
//global replace
var strVal = "x25_10id:333|x46_30id:400|x64_13id:500";
//alert(strVal.replace(new RegExp('|', 'g'), ';'));
function escape(s) {
return s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
};
function replace_all(string, pattern, replacement){
return string.replace( new RegExp(escape(pattern), "g"), replacement);
}
alert(replace_all(strVal, "|", ";"));