string replace all node code example
Example 1: 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 2: javascript replaceall
//as of August 2020, not supported on older browsers
str.replaceAll("abc","def")