I’m sure somebody will be able to help me on this; I’m trying to replace 🙂 with the word smiley – The following works but only replaces the first string:
var string = "hello :)";
string = string.replace(":)", "smiley");
I tried this but it won’t work:
var string = "hello :)";
string = string.replace(/:)/g, "smiley");
Any ideas?
You’re on the right track with your second example, but the
/.../gnotation creates a regular expression, and)has a special meaning in a regular expression; you need to “quote” or “escape” it with a backslash: