# String representation of expression

**URL:** https://discourse.julialang.org/t/string-representation-of-expression/36729
**Category:** General Usage
**Tags:** question, macros
**Created:** [March 30, 2020, 10:20am UTC](https://discourse.julialang.org/t/string-representation-of-expression/36729 "2020-03-30T10:20:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![pfarndt](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@pfarndt](https://discourse.julialang.org/u/pfarndt)
#### Post date: [March 30, 2020, 10:20am UTC](https://discourse.julialang.org/t/string-representation-of-expression/36729/1 "2020-03-30T10:20:06Z")

</div>

I once developed a macro which would take the enclosed code block and write it to a file which would then later be `include`d in another julia process. In principle I just `print`ed the expression into the file which would then happly run once included - in **julia v1.3** :

```julia
julia-1.3> print(:(r = r"""45 " """))
r = #= REPL[1]:1 =# @r_str("45 \" ")

```

However with **julia v1.4** this does not work anymore, since quotes in triple-quoted strings and escaped quotes in quoted strings are not faithfully represented anymore if they appear in a non-standard string literal:

```julia
julia-1.4> print(:(r = r"""45 " """))
r = r"45 " "

```

```julia
julia-1.4> print(:(r = r"45 \" "))
r = r"45 " "

```

in normal string everything seems fine:

```julia
Julia-1.4> print(:(r = "45 \" "))
r = "45 \" "

```

Is there another way I should use to print an expression such that it can be included again?

Thanks

---

<div class="post-metadata">

### Author: ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)
#### Post date: [March 30, 2020, 11:00am UTC](https://discourse.julialang.org/t/string-representation-of-expression/36729/2 "2020-03-30T11:00:10Z")

</div>

Probably not a great answer (and probably overkill) but:

```julia
julia> print(:(r = $(esc(r"""45 " """).args[1])))
r = r"45 \" "

```

on nightly

---

<div class="post-metadata">

### Author: ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)
#### Post date: [March 30, 2020, 12:10pm UTC](https://discourse.julialang.org/t/string-representation-of-expression/36729/3 "2020-03-30T12:10:25Z")

</div>

This looks like a printing bug. Could you open an issue on GitHub?

---

<div class="post-metadata">

### Author: ![pfarndt](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@pfarndt](https://discourse.julialang.org/u/pfarndt)
#### Post date: [March 30, 2020, 1:40pm UTC](https://discourse.julialang.org/t/string-representation-of-expression/36729/4 "2020-03-30T13:40:08Z")

</div>

Done: [https://github.com/JuliaLang/julia/issues/35305#issue-590299078](https://github.com/JuliaLang/julia/issues/35305#issue-590299078)
