Answers for "how to write a string and then replace it in html"

31

javascript replace

var res = str.replace("find", "replace");
Posted by: Guest on October-21-2019
0

replace javascript

// Replace with no modifiers
let newText = startText.replace("yes", "no")
console.log(newText)  // "Yes, I said no, it is, yes."

// Replace with 'g'-global modifier
newText = startText.replace(/yes/g, "no")
console.log(newText)  // "Yes, I said no, it is, no."

// Replace with modifiers 'g'-global and 'i'-case insensitive
newText = startText.replace(/yes/gi, "no")
console.log(newText)  // "no, I said no, it is, no."
Posted by: Guest on December-30-2020

Code answers related to "how to write a string and then replace it in html"

Code answers related to "Javascript"

Browse Popular Code Answers by Language