Reputation: 44066
I have the string R.E.M
. and I need to make it REM
So far, I have:
$('#request_artist').val().replace(".", "");
...but I get RE.M
.
Any ideas?
Upvotes: 9
Views: 6991
Reputation: 1038930
You could pass a regular expression to the replace method and indicate that it should replace all occurrences like this: $('#request_artist').val().replace(/\./g, '');
Upvotes: 4
Reputation: 68
The method used to replace the string is not recursive, meaning once it found a matching char or string, it stop looking. U should use a regular expression replace.
$("#request_artist").val().replace(/\./g, '');
Check out Javascript replace tutorial for more info.
Upvotes: 2
Reputation: 449495
The first argument to replace()
is usually a regular expression.
Use the global modifier:
$('#request_artist').val().replace(/\./g, "");
Upvotes: 17