I want to use str_replace
or its similar alternative to replace some text in JavaScript.
var text = \"this is some sample text that i want to re
Use JS String.prototype.replace
first argument should be Regex pattern or String and Second argument should be a String or function.
str.replace(regexp|substr, newSubStr|function);
Ex:
var str = 'this is some sample text that i want to replace';
var newstr = str.replace(/want/i, "dont't want");
document.write(newstr); // this is some sample text that i don't want to replace