JS - replace character

0 votes
284 views
added May 31, 2018 in Javascript by anonymous
edited Jul 13, 2018 by LC Marshal
//Replaces all spaces with '-'!
city_name=city_name.replace(/ /gi,'-');

2 Responses

0 votes
responded May 31, 2018 by anonymous
edited Jul 13, 2018 by LC Marshal
var text = "I love you no matter what";
var new_text = text.replace("love", "hate");
document.write(new_text);
0 votes
responded Aug 6, 2019 by anonymous
var str="Test:";
document.write(str.replace(/:/g, ""));

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...