So, I have the following:
var token = '[token]'; var tokenValue = 'elephant'; var string = 'i have a beautiful [token] and i sold my [token]'; string = string.replace(token, tokenValue);
The above will replace only the first [token] and leave the second on.
If I used a regex, I could use it as
string = string.replace(/[token]/g, tokenValue);
And that will replace all my [tokens]
However, I do not know how to do this without using //
source share