An easy way to parse escaped newline character?

I’m not sure how exactly you would end up with a string containing "\\n" (i.e. a forward slash and a letter n), but I suppose you could just use replace(..., "\\n" => '\n'). With line = replace(readline(f, keep=true), "\\n" => '\n'), the output becomes

julia> mweesc()
line 1:
this
is
line[5] = '
'
this
is
str[5] = '
'
line 2:
a test of escaped
newlines
line[5] = 's'
a test of escaped
newlines
str[5] = 's'
1 Like