Am incercat asa:
Cod: Selectaţi tot
let str ='This is my text';
str = str.replace(/\s/, '-');
console.log(str); // This-is my text
Cum pot face ca replace() sa inlocuiasca toate potrivirile formatului regex in sir?
Cod: Selectaţi tot
let str ='This is my text';
str = str.replace(/\s/, '-');
console.log(str); // This-is my text
Cod: Selectaţi tot
let str ='This is my text';
str = str.replace(/\s/g, '-');
console.log(str); // This-is-my-text