JSFiddle - React, Tailwind, and code Playground
JavaScript
const searchRegExp = /\s/g;
const replaceWith = '-';
const result = 'duck duck go'.replace(searchRegExp, replaceWith);
console.log(result); // => 'duck-duck-go'
const searchRegExp = /\s/g;
const replaceWith = '-';
const result = 'duck duck go'.replace(searchRegExp, replaceWith);
console.log(result); // => 'duck-duck-go'