Hello Reader's!
If you want to replace multiple sting with another multiple stings, then you use the JS function as below:-
Lets say a given sentence having strings.
var str = "I have a cat, a dog, and a goat."; //sentence to process
var mapObj = {
cat:"dog", //specify what word will replace with another words.
dog:"goat",
goat:"cat"
};
str = str.replace(/cat|dog|goat/gi, function(matched){
return mapObj[matched];
});
alert(str);
0 Comment(s)