Answers for "replace ? to '" ' in javascript replace method"

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 "Javascript"

Browse Popular Code Answers by Language