I have a string that contains multiple spaces. I want to replace these with a plus symbol. I thought I could use

var str="a b c";
var replaced = str.replace(' ', '+');

but it only replaces the first occurrence. How can I get it replace all occurrences?

9 Answers
9

Leave a Reply

Your email address will not be published. Required fields are marked *