Answers for "js string.replace spaces"

14

js replace space with underscore

var string = "my name";
string = string.replace(/ /g,"_"); //returns my_name
Posted by: Guest on April-24-2020
2

string replace javascript

let re = /apples/gi; 
let str = "Apples are round, and apples are juicy.";
let newstr = str.replace(re, "oranges"); 
console.log(newstr)

output:

"oranges are round, and oranges are juicy."
Posted by: Guest on November-23-2020
0

javascript replace spaces with br

str = str.replace(/\s/g, "<br>");
Posted by: Guest on November-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language