Javascript has a built-in function to replace a value found in a String with another value.
string.replace("match","replacement");
The problem is that it only does this replacement one time.
To replace all instances of a value in the string, you can combine two other functions -- split and join.
var myResult = myString.split("match").join("replacement");
No comments :
Post a Comment