Javascript: String Replace More Than Once / All Instances of A Value

Javascript has a built-in function to replace a value found in a String with another value.

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