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?
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?
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, '');
The first argument to replace()
is usually a regular expression.
Use the global modifier:
$('#request_artist').val().replace(/\./g, "");
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.