%% Erlang Program to Parse a list/string
%% Date : 19-Aug-2009
%% Author: Prakhar Dubey :prakharprakhar@gmail.com
%% Program shows the use of string:tokens, list iterator and
%% fun callback function.
-module(parse).
-export([init/0]).
init() ->
Str = "tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!tool.,www.tool.com.,2081991958,34!sun.com.,www.starplus.com.,3252467389,39!",
B = string:tokens(Str,"!"),
Print = fun(L) -> io:format("Values:~p~n",[L]) end,
Callback = fun(E) -> C = string:tokens(E,","),lists:foreach(Print,C), io:format("Element:~p~n",[E]) end,
lists:foreach(Callback,B),
ok.
No comments:
Post a Comment