Possible Duplicate:
Why does javascript replace only first instance when using replace?
How do I replace all occurrences of “/” in a string with “_” in JavaScript?
I want to replace every -
in a sentence but it only replace the first -
. Here is my code:
var string = 'this-is-a-line-of-words';
alert(string.replace('-', '/'));
Why does it only replace the first character I want to replace? jsFiddle demo.
Thanks in advance.