[erlang-questions] string conversion
Attila Rajmund Nohl
attila.r.nohl@REDACTED
Fri Jun 19 19:08:34 CEST 2009
This time sending to the list too...
2009/6/19, info <info@REDACTED>:
> Hi All,
> How to simplify the P1-P2-P3 sequence:
>
> {ok, Bin} = file:read_file("example.xml"), % read a binary string
> P1 = re:replace(Bin,"\\s","",[global]), % remove all
> whitespaces
> P2 = list_to_binary(P1), % convert [list] in
> binary
> P3 = binary_to_list(P2), % convert binary to
> list
>
> I = str(P3,"string_to_find"), % str(list,list)
>
> str(P1,"string_to_find") hangs. That is why I used this trick but it is not
> a good code ...
Haven't tried, but
P1 = re:replace(Bin,"\\s","",[global, {return list}]),
doesn't help? By the way, it might be useful to set the return type
globally for the re application...
More information about the erlang-questions
mailing list