javascript replace spaces with dashes
snippet in javascript

javascript replace spaces with dashes

user766

title = title.replace(/\s/g , "-");

javascript replace all spaces with dashes

user7193

let originalText = 'This is my text';
let dashedText = originalText.replace(/ /g, '-');