Search code examples
stringescapingstring-literalsjulia

Raw literal strings in Julia


In Python one can write r"a\nb" in order to prevent the \n from being interpreted as an escape sequence for newline.

Is there something similar in Julia? And what about string interpolation like "$variable", is there a way to prevent it?

I know one can simply write "a\\nb" and "\$variable" in Julia, but I would like to write a lot of LaTeX strings without having to care to proper escape every backslash \ and dollar $ characters...

(In Julia, r"..." creates a regular expression.)


Solution

  • From Julia 0.6 we have raw"\a$variable"