I’m trying to create a sort of ‘template’ in plain old html, which can then have elements inserted by another javascript function.
So, I’ve got
var string = "<div id='<@nameInsert>' style='padding: 2px;'>here's some text and stuff</div>";
And in a function I’m trying to replace <@nameInsert> with the name I’m using…
string.replace("/<@nameInsert>", "525");
But, it don’t work. Some sort of escaping thing, wrong idea this, or what?
Don’t use quotes if you want to use regular expressions
But in your case you don’t really need regular expressions. Just use a string: