squiblo Posted April 21, 2010 Share Posted April 21, 2010 The first parameter in the replace function is incorrect but I do not know the right way of putting it. var replace4_1 = "*(#92)*"; // \ var message1 = message1.replace(/\/g, replace4_1); Thanks Quote Link to comment Share on other sites More sharing options...
salathe Posted April 21, 2010 Share Posted April 21, 2010 Use two backslashes: replace(/\\/g, replace4_1) Without the second backslash (or first, depending how you look at it), JavaScript thinks that you are trying to escape the second forward slash. Quote Link to comment Share on other sites More sharing options...
squiblo Posted April 21, 2010 Author Share Posted April 21, 2010 Thank you salathe, that has worked perfect, i also have another small problem, the following does not work var message1 = message1.replace(/+/g, replace5_1); Quote Link to comment Share on other sites More sharing options...
salathe Posted April 21, 2010 Share Posted April 21, 2010 Use a backslash: replace(/\+/g, replace5_1) Without the backslash, JavaScript thinks that you are trying to use a quantifier (to match one or more of something, e.g. a+) yet there is nothing to quantify so it throws an error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.