javascript regular expression replace code example
Example 1: javascript replace string
var str = "JavaScript replace method test";
var res = str.replace("test", "success");
Example 2: js replace characters in a string
var str = "Original string!";
var str = str.replace("Original", "New");
Example 3: javascript regex replace
const search = 'duck'
const replaceWith = 'goose';
const result = 'duck duck go'.replaceAll(search, replaceWith);
result;
Example 4: javascript replace
var frase = "Son tres mil trescientos treinta y tres con nueve";
frase = frase.replace("tres","dos");
console.log(frase);