# An easy way to parse escaped newline character?

**URL:** <https://discourse.julialang.org/t/an-easy-way-to-parse-escaped-newline-character/124188>\
**Category:** General Usage\
**Created:** [December 26, 2024, 4:37pm UTC](https://discourse.julialang.org/t/an-easy-way-to-parse-escaped-newline-character/124188 "2024-12-26T16:37:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [December 26, 2024, 5:05pm UTC](https://discourse.julialang.org/t/an-easy-way-to-parse-escaped-newline-character/124188/2 "2024-12-26T17:05:34Z")

</div>

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-repl
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'

```

---

_[View the full topic](https://discourse.julialang.org/t/an-easy-way-to-parse-escaped-newline-character/124188)._
