# Triple double quote not acting as expected

**URL:** <https://discourse.julialang.org/t/triple-double-quote-not-acting-as-expected/8652>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [January 28, 2018, 12:04pm UTC](https://discourse.julialang.org/t/triple-double-quote-not-acting-as-expected/8652 "2018-01-28T12:04:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hotcode](https://avatars.discourse-cdn.com/v4/letter/h/858c86/32.png) [@hotcode](https://discourse.julialang.org/u/hotcode)\
**Post date:** [January 28, 2018, 12:04pm UTC](https://discourse.julialang.org/t/triple-double-quote-not-acting-as-expected/8652/1 "2018-01-28T12:04:42Z")

</div>

“”“I am a “string” “””  
works OK - notice the space

“”“I am a “string””“”  
does not work - julia expects yet another closing double quote  
this seems strange to me!

“”“I am a “string” “””"  
this works OK, but has (as far as I understand the theory) one closing double quote too much …

What am I missing?

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [January 28, 2018, 4:25pm UTC](https://discourse.julialang.org/t/triple-double-quote-not-acting-as-expected/8652/2 "2018-01-28T16:25:24Z")

</div>

You need to escape quotation marks in a string with a backslash:

```julia
"""I am a \"string\""""

```

Edit: sorry, I guess from [https://docs.julialang.org/en/stable/manual/strings/#Triple-Quoted-String-Literals-1](https://docs.julialang.org/en/stable/manual/strings/#Triple-Quoted-String-Literals-1) you would think that `"""I am a "string""""` should work too.

The behavior is different on latest master:

```julia
julia> """I am a "string""""
ERROR: syntax: cannot juxtapose string literal

```

which was a result of [https://github.com/JuliaLang/julia/issues/20575](https://github.com/JuliaLang/julia/issues/20575).

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [January 28, 2018, 6:50pm UTC](https://discourse.julialang.org/t/triple-double-quote-not-acting-as-expected/8652/3 "2018-01-28T18:50:20Z")

</div>

Julia only looks at the triple as an end-marker — the parser isn’t keeping track of open/close “…” pairs inside the triple. Need to escape the first in the ending “”“” sequence.

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [January 28, 2018, 7:47pm UTC](https://discourse.julialang.org/t/triple-double-quote-not-acting-as-expected/8652/4 "2018-01-28T19:47:02Z")

</div>

`"""I am a "string""""` is being parsed as `"""I am a "string"""` followed by a `"`, and that is why (as at-ihnorton) said, the first " in the final sequence needs to be quoted.  
If you have wish to have more than 2 `"` in a row in a triple-quoted string, then you need to use `\` on every 3rd one, for example, to have 6 `"` inside a triple-quoted string, you’d need to have `""\"""\"`.

---

<div class="post-metadata">

**Author:** ![hotcode](https://avatars.discourse-cdn.com/v4/letter/h/858c86/32.png) [@hotcode](https://discourse.julialang.org/u/hotcode)\
**Post date:** [January 29, 2018, 2:27pm UTC](https://discourse.julialang.org/t/triple-double-quote-not-acting-as-expected/8652/5 "2018-01-29T14:27:01Z")

</div>

That’s what I realized later. Thx to all!
