[erlang-questions] Fwd: clarify: escaping strings in erl_scan:string / erl_parse:parse_term

Vlad Dumitrescu vladdu55@REDACTED
Fri Dec 28 14:38:37 CET 2007


Hi,

On Dec 28, 2007 2:26 PM, Roberto Saccon <rsaccon@REDACTED> wrote:
> But if I try to do the same with erl_scan:string and
> erl_parse:parse_term, it is tokenizing not as expected and parsing
> gives an error:
>
>
> 2> {ok,Tokens,_}=erl_scan:string("{a_string, \"foo(\"hi\")\"}.").

You have to escape even the backslashes in the inside string, like this:

{ok,Tokens,_}=erl_scan:string("{a_string, \"foo(\\\"hi\\\")\"}.").


best regards,
Vlad

--
Some people see things that are and ask, Why?
Some people dream of things that never were and ask, Why not?
Some people have to go to work and don't have time for all that.
--- George Carlin



More information about the erlang-questions mailing list