Yes this is expected.The \$ causes a dollar sign to be inserted into the string rather than doing the normal string replacement.
If you want to write abc.\$foo to a file you would need to declare the string like “abc.\\\$foo”. Or maybe you could do something like string(“abc.”, “\\”, “$”, “foo”) if that would be easier to read. You need the double slash to avoid escaping the end quote…
Julia is printing a \ because it’s trying to helpfully show you what you would need to input to re-create the string you have. You need the \$ to get the literal $ in the resulting string.
Thanks - yes, that makes total sense, of course the \$ simply escapes the interpolation. I was trapped in between the JS and JL worlds where I was generating JL files which contain Julia functions which generate JS code which contains $ variables and at some point my brain turned off.