I need to take all plus symbols from a variable and replace them with spaces. I have tried:
someVariable = "0+123+45+6";
someVariable.replace(/+/g, ' ');
But this doesn’t work… what would be the correct syntax for this situation?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
the
+is a special char (one or more), so you need to escape it.should be
/\+/gEDIT
the regular expression does not modify the string object itself. but returns the result.