[erlang-questions] Split string in nested list

Weerasak Chongnguluam <>
Fri Feb 11 18:33:29 CET 2011


Sorry I'm incorrect argument pattern.

lists:map(fun([URL]) ->
   if is_atom(URL) ->
       string:tokens(atom_to_list(
>
> URL),"@");
>       true ->
>        string:tokens(URL,"@")
>    end
>    end,[[""],[],[]]
>    ).


2011/2/12 Weerasak Chongnguluam <>

> Hi,
>
> You can use lists:map with string:tokens, like this.
> lists:map(fun(URL) ->
>    if is_atom(URL) ->
>        string:tokens(atom_to_list(URL),"@");
>       true ->
>        string:tokens(URL,"@")
>    end
>    end,[[""],[],[]]
>    ).
>
> On Fri, 2011-02-11 at 08:50 -0800, shk wrote:
> > Hello,
> >
> > I have list of next view:
> >
> > [[""],[],[]]
> >
> > How can i split by '@" this list?
> >
> > I need following:
> >
> > [["admin", "localhost"], ["localhost", "localhost"], [user, localhost]]
> >
> > Thank you.
>
>
>


More information about the erlang-questions mailing list