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

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

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

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

Occurs randomly as you detect it first

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> str = "\"hello,\"world\""
"\"hello,\"world\""

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

Bingo ! Thanks !

"\""

In real is not work becouse

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

not works

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

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

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

i must replce “\” for "

e.g.

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

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.

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

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

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.

1 Like