Reputation: 11
i have a string :
var s="here_we_go";
how can i replace all occurrence of '_' by '$' so the string will become:
s="here$we$go";
Upvotes: 1
Views: 2061
Reputation: 523154
s.replace(/_/g, '$');
The g
here ensures every (not just one) occurrences of _
will be replaced by $
.
Upvotes: 7