Problem with "\" , how to use in Dict {Any}?

julia> usuwam
Dict{Any,Any} with 6 entries:
“=” => “”
“!” => “”
“-” => “”
“/” => “”
“‘’” => “”
“+” => “”

Is ok, but :
julia> get!(usuwam,“backslash”,“”)
not work ! how to use “backslash” in Dict {Any} ?
Paul

I think you want "\\". See C syntax - Wikipedia

Note also that if your dictionary keys are all single characters, you can use Char instead of String, i.e. '=', '\\', etcetera. Note also that you can have a typed dictionary, e.g. Dict{String,String} or Dict{Char,String}.

https://xkcd.com/1638/

5 Likes

Unfrotunatly , \ no works :confused:

get!(B,“\”,“”)
“”
B
Dict{String,String} with 3 entries:
“,” => “”
“:” => “”
“\” => “”

replace(x,‘\’,‘u’)
“adam\a”

replace(x,‘a’,‘u’)
“udum\a”

replace(x,‘\’,‘u’)
“adam\a”

replace(x,“\”,‘u’)
“adam\a”

Some ideas ?
Paul

W dniu 2018-02-11 o 13:35, Steven G. Johnson pisze:

Please provide a minimal working example, with code that can be copied and pasted, as well as describing precisely what you expect to happen.

A have to clearing text from dirti HTML like dhis:

only=sort(split(text_only(doc.root[2]) ))
2472-element Array{SubString{String},1}:
“!”
“"”
“"Bezlitosny”
“"Była”
“"Coś”
“"Decyzja”
“"Diablo"”
“"Dzień”
“"Elisabeth,”
“"Familiady"”
“"Lampka”
“"Loteria”

and now i am makeing Dict with NoLeters Char to remove it
backslash is one of this…
my list:
!

Please provide a simplified version that everybody can copy and paste to define the variables.

Also, please quote your code using backticks (`)

`
julia> get!(x,‘!’,“”)
“”

julia> get!(x,‘',“”)
ERROR: syntax: invalid character literal
julia> get!(x,’\',“”)
“”
julia> x
Dict{Char,String} with 4 entries:
‘!’ => “”
‘\’ => “”
’ ’ => “”
‘"’ => “”
`

Char(92) == ‘\’ # true

You must escape the backslash character, as for example '\\'. Note there are two backslashes written here, but this is actually a single backslash character.