How to convert a raw string to escape $

The raw_string you create is not actually a raw string, it’s a Regex. To create a raw string, prepend the string with raw rather than r.

julia> r_string = r"the price of the ticket is 10$"
r"the price of the ticket is 10$"

julia> typeof(r_string)
Regex

julia> raw_string = raw"the price of the ticket is 10$"
"the price of the ticket is 10\$"

julia> println(raw_string)
the price of the ticket is 10$

Check the help entries for @r_str and @raw_str for more info.

5 Likes