JavaScript Substitua parte da string
let str = "Our are awesome!";
let txt = str.replace("Our", "We");
console.log(txt); // We are awesome!
Yanislav Ivanov
let str = "Our are awesome!";
let txt = str.replace("Our", "We");
console.log(txt); // We are awesome!
var str = "Please locate where 'locate' occurs!";
str.replace("locate", "W3Schools"); //replace only replace first match from string
str.replace(/LOCATE/i, "W3Schools"); // i makes it case insensitive
str.replace(/LOCATE/g, "W3Schools"); // g replace all matches from string rather than replacing only first
document.write("<br>" + "replace:", res7);
document.write("<br>" + "replace with case insensitive:", res8);
document.write("<br>" + "replace all:", res9);
var str = "JavaScript replace method test";
var res = str.replace("test", "success");
//res = Javscript replace method success
var res = str.replace("find", "replace");
const p = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?';
console.log(p.replaceAll('dog', 'monkey'));
// expected output: "The quick brown fox jumps over the lazy monkey. If the monkey reacted, was it really lazy?"
str.replace('tobereplaced', 'replacement'),