Not sure why but i can’t seem to replace a seemingly simple placeholder.
My approach
var content = 'This is my multi line content with a few {PLACEHOLDER} and so on';
content.replace(/{PLACEHOLDER}/, 'something');
console.log(content); // This is multi line content with a few {PLACEHOLDER} and so on
Any idea why it doesn’t work?
Thanks in advance!
JavaScript’s string replace does not modify the original string.
Also, your code sample only replaces one instance of the string, if you want to replace all, you’ll need to append ‘g’ to the regex.