[erlang-questions] Problems in a list

Christian S <>
Thu Aug 16 12:48:21 CEST 2007


Do you want to parse erlang terms?

Quick solution:

{ok, Tokens, _} = erl_scan:string("[\"abc\", \"def\"].").
{ok, Parse} = erl_parse:parse_term(Tokens).
Parse = ["abc","def"].

However, there might be reasons to not use this method to parse data,
if you dont trust the data you parse, a malicious user could fill up
your atom tables with nonsense atom names.

If that is not an issue you just need to take your String and
lists:flatten([$[, String, $], $.]) to get the string you pass erl_scan:string/1

If it is an issue, implement your own parser.

2007/8/16, Prabhuram K <>:
> Hello all,
> I am a newbie to erlang.
> I have a value of this format "\"srs1\",\"srs2\"". If I do a list_to_atom on
> this I get '"srs1","srs2"', that is within single quote. So if I store it as
> [SrsNameList] it is stored as ['"srs1","srs2"'].  I don't need the single
> quote, it should just be ["srs1","srs2"]. How do I do that ?
>
>
> Thanks in advance,
>
> --Prabhu
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list