How to remove quotation marks

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to remove quotation marks

Faustin Ngokse
Hi erlang friends,

I don't know if some of you solved this problem before;
I have an erlang term enclosed in quotation marks and I just want to remove the
quotation marks.
Does anyone know an elegant way how to do that?

example:
How to transform
List = "[{hello1}, {hello2}]"
into
Term = [{hello1}, {hello2}]

Thanks in advance
/// Faustin



Reply | Threaded
Open this post in threaded view
|

How to remove quotation marks

Samuel Elliott
On 27/05, Faustin Ngokse wrote:

| I have an erlang term enclosed in quotation marks and I just want to
| remove the quotation marks.
| Does anyone know an elegant way how to do that?
|
| example:
| How to transform
| List = "[{hello1}, {hello2}]"
| into
| Term = [{hello1}, {hello2}]

The Erlang shell does that, the full source should be available on your system
(look for shell.erl and erl_eval.erl).

  Sam



Reply | Threaded
Open this post in threaded view
|

How to remove quotation marks

Ulf Wiger-4
In reply to this post by Faustin Ngokse

1> List = "[{hello1}, {hello2}]".
"[{hello1}, {hello2}]"
2> {ok,Tokens,_} = erl_scan:string(List ++ ".").
{ok,[{'[',1},
     {'{',1},
     {atom,1,hello1},
     {'}',1},
     {',',1},
     {'{',1},
     {atom,1,hello2},
     {'}',1},
     {']',1},
     {dot,1}],
    1}
3> erl_parse:parse_term(Tokens).
{ok,[{hello1},{hello2}]}


/Uffe

On Mon, 27 May 2002, Faustin Ngokse wrote:

>Hi erlang friends,
>
>I don't know if some of you solved this problem before;
>I have an erlang term enclosed in quotation marks and I just
>want to remove the quotation marks.
>Does anyone know an elegant way how to do that?
>
>example:
>How to transform
>List = "[{hello1}, {hello2}]"
>into
>Term = [{hello1}, {hello2}]
>
>Thanks in advance
>/// Faustin
>
>

--
Ulf Wiger, Senior Specialist,
   / / /   Architecture & Design of Carrier-Class Software
  / / /    Strategic Product & System Management
 / / /     Ericsson Telecom AB, ATM Multiservice Networks