replace regex code example
Example 1: javascript regex replace
const search = 'duck'
const replaceWith = 'goose';
const result = 'duck duck go'.replaceAll(search, replaceWith);
result; // => 'goose goose go'
Example 2: regex replace /
// replaces all / in a String with _
str = str.replace(/\//g,'_');
Example 3: replace js
// Replace All
str = str.replace(/_/g, ' ');