Bran Gi
Bran Gi

Reputation: 147

Remove & quote; and elements of a list ( erlang )

I have a record list which I want to display as a string, and then pass to an XML attribute:

Li = (get the record),

LOOKS LIKE:

?INFO_MSG("LIST::::: ~p~n", [?SETS:to_list(Li)]),
[{"9993939","some.com",[]}, {"12341234","some.com",[]}]

I remove some duplicates with :

Li = ?SETS:to_list(List)
Set = sets:from_list(Li)
O = sets:to_list(Set)

after this I use io_lib:format to get my final string:

OO = io_lib:format("~p", [O])

but when I provide it to the XML it comes with & quote; characters,

"[{& quote;9993939& quote;,& quote;some.com& quote;,[]},{&
quote;12341234&& quote;,& quote;some.com& quote;,[]}]"

how can I remove those characters?

Actually my final goal

from this:

"[{"9993939","some.com",[]}, {"12341234","some.com",[]}]"

get only the numbers on the list:

"[9993939,12341234]"

Upvotes: 0

Views: 514

Answers (1)

Jr0
Jr0

Reputation: 2173

Your question is very vague... hard to understand, but is this what you want?

-module(vague).
-compile(export_all).

extract(Li)->
    [Element || {ok, [Element],[]} <- [io_lib:fread("~d", Projection) ||
                                          {Projection, _, _} <- Li]].


1> vague:extract([{"9993939","some.com",[]}, {"12341234","some.com",[]}]).
   [9993939, 12341234]

Upvotes: 1

Related Questions