Raw string literals
If you need to define a string that does not perform interpolation or escaping, for example to represent code from another language that might contain$
and\
which can interfere with the Julia parser, you can use raw strings. They are constructed withraw"..."
and create ordinaryString
objects that contain the enclosed characters exactly as entered, with no interpolation or escaping:
julia> "This $will error out"
ERROR: UndefVarError: will not defined
Putting a $
inside the string will cause Julia to perform interpolation and look for a variable called will
:
julia> raw"This $will work"
"This \$will work"
But by using a raw string, the $
symbol will be ignored (or rather, automatically escaped, as you can see in the output).