[erlang-questions] Split string in nested list

Weerasak Chongnguluam singpor@REDACTED
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,[["admin@REDACTED"],[localhost@REDACTED],[user@REDACTED]]
>    ).


2011/2/12 Weerasak Chongnguluam <singpor@REDACTED>

> 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,[["admin@REDACTED"],[localhost@REDACTED],[user@REDACTED]]
>    ).
>
> On Fri, 2011-02-11 at 08:50 -0800, shk wrote:
> > Hello,
> >
> > I have list of next view:
> >
> > [["admin@REDACTED"],[localhost@REDACTED],[user@REDACTED]]
> >
> > 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