I have the following code using the javascript replace but not all instances are being replaced:
var str = '9c88a4f84d6b0c94-3e8a-ca0a320c6509';
str = str.replace("-", "");
alert(str);
What am I missing?
I have the following code using the javascript replace but not all instances are being replaced:
var str = '9c88a4f84d6b0c94-3e8a-ca0a320c6509';
str = str.replace("-", "");
alert(str);
What am I missing?
It's replacing the first one. That's what it does when you give it a string. To replace all of them, use a regular expression with the g
flag:
str = str.replace(/-/g, "");