Let's say I have this string
"examples\output\$projectname$\$projectname$.csproj"
I want to replace all occurences of $projectname$ with some string. E.g. replacing it with TEST should yield:
"examples\output\TEST\TEST.csproj"
The closest I've come to achieving this is:
("examples\output\$projectname$\$projectname$.csproj")
.replace(new RegExp("\\$projectname\\$", "g"), "TEST");
which yields:
"examplesoutputTESTTEST.csproj"
Even when writing...
("examples\output\$projectname$\$projectname$.csproj")
.replace(new RegExp("output", "g"), "TEST");
...this will still remove the backslashes
"examplesTEST$projectname$$projectname$.csproj"
Why is this happening and how do I prevent this?