# How do I get rid of the string fragment \\\\"

**URL:** <https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240>\
**Category:** General Usage\
**Created:** [October 5, 2021, 2:55pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240 "2021-10-05T14:55:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [October 5, 2021, 2:55pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/1 "2021-10-05T14:55:07Z")

</div>

I have in log part of line: “\“Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_15\_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36\””

How do I get rid of the string fragment: \"  
On the start end on the end ?  
This string is in s after cooomand s=readline(fh)  
Paul

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 5, 2021, 2:57pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/2 "2021-10-05T14:57:17Z")

</div>

```julia
julia> str = "\"hello, world\""
"\"hello, world\""

julia> chop(str; head=1, tail=1)
"hello, world"

```

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [October 5, 2021, 3:10pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/3 "2021-10-05T15:10:56Z")

</div>

> [@fredrikekre](#):
>
> `chop(str; head=1, tail=1)`

Occurs randomly as you detect it first

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 5, 2021, 3:12pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/4 "2021-10-05T15:12:41Z")

</div>

Randomness of what? You asked for removing it at the start and the end. If you want to remove all `"` in a string you can use `replace`:

```julia
julia> str = "\"hello,\"world\""
"\"hello,\"world\""

julia> replace(str, "\"" => "")
"hello,world"

```

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [October 5, 2021, 3:17pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/5 "2021-10-05T15:17:21Z")

</div>

> [@fredrikekre](#):
>
> `"\""`

Bingo ! Thanks !

```julia
"\""

```

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [October 5, 2021, 3:39pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/6 "2021-10-05T15:39:48Z")

</div>

In real is not work becouse

```julia
replace(s, ""\"" => """)

```

not works

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 5, 2021, 3:45pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/7 "2021-10-05T15:45:36Z")

</div>

You have too many quotation marks. Please make sure you are carefully following what they wrote

```julia
julia> str = "\"hello,\"world\""
"\"hello,\"world\""

julia> replace(str, "\"" => "")
"hello,world"

```

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [October 5, 2021, 3:49pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/8 "2021-10-05T15:49:59Z")

</div>

i must replce “\” for "

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [October 5, 2021, 3:52pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/9 "2021-10-05T15:52:02Z")

</div>

e.g.

“\“Mozilla/5.0 =\> “Mozilla/5.0

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 5, 2021, 4:29pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/10 "2021-10-05T16:29:14Z")

</div>

In the figure, please paste the strings _with backticks_ so that there is less confusion between `”` and `"`.

It’s still not obvious what you want to do. But `replace(s, "”" => "\""`) should work.

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [October 5, 2021, 4:44pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/11 "2021-10-05T16:44:42Z")

</div>

Thanks, but this other quotation mark is then not understood in the readdlm () command as a text character

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [October 5, 2021, 4:49pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/12 "2021-10-05T16:49:51Z")

</div>

In really I need  
`replace(s, ""\""=> """)) `  
but not work

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [October 5, 2021, 5:37pm UTC](https://discourse.julialang.org/t/how-do-i-get-rid-of-the-string-fragment/69240/13 "2021-10-05T17:37:27Z")

</div>

Welcome to the world of escaped characters. You can’t keep a `"` in a string, because how will it know the difference between that and the end of the string? So you _escape_ the quotation mark with a backslash. Note that this is just what it looks like for there to be a quotation mark in the string. If you for instance do `println("\"apples\"")` you’ll see there’s no problem there.

If you want an easier time inputting these special characters, you can try `"""long "strings", which"""` don’t suffer from this.
