I need to replace the word _New+Delivery; in a string with comma ( ',')
sample input string : XP_New+Delivery;HP_New+Delivery;LA_New;
expected output : XP,HP,LA_New;
But it is returning the same input as output, not replacing anything any idea?
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var res = str.replace(new RegExp('_New+Delivery;', 'gi'), ',');
document.getElementById("demo").innerHTML = res;
}
<p id="demo">XP_New+Delivery;HP_New+Delivery;LA_New;</p>
<button onclick="myFunction()">Try it</button>