javascript replaceall regex code example
Example 1: js replace characters in a string
var str = "Original string!";
var str = str.replace("Original", "New");
Example 2: string replace javascript
let re = /apples/gi;
let str = "Apples are round, and apples are juicy.";
let newstr = str.replace(re, "oranges");
console.log(newstr)
output:
"oranges are round, and oranges are juicy."
Example 3: replace javascript
let newText = startText.replace("yes", "no")
console.log(newText)
newText = startText.replace(/yes/g, "no")
console.log(newText)
newText = startText.replace(/yes/gi, "no")
console.log(newText)