I have a sting that has embedded ":
tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">
how can i present such a string as a value in Elixir?
for example:
iex> s= "tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">"
Using ~s and ~S did not help
iex(20)> s=~S("tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">")
** (SyntaxError) iex:20: keyword argument must be followed by space after: w:
iex(20)> s=~s("tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">")
** (SyntaxError) iex:20: keyword argument must be followed by space after: w:
iex(20)>
You can escape the double quotes:
s ="tx <iq id=\"wUcdTMYuYoo41\" to=\"2348138248411@\" type=\"set\" xmlns=\"w:profile:picture\">"
There is a sigil_s to make this more convenient (there is also sigil_S which doesn't interpolate variables):
s = ~s(tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">)
Quotes are also escaped when using multi-line strings (heredocs):
"""
tx <iq id="wUcdTMYuYoo41" to="2348138248411@" type="set" xmlns="w:profile:picture">
"""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With