1
我嘗試從MIME郵件消息中獲取TO:[email protected]字段。erlang mime get To字段
我有代碼:
parse_to(Data) ->
List = string:tokens(Data, ":"),
Sep1 = lists:map(fun(H) ->string:tokens(H, ":") end, List),
io:format(Sep1),
Sep2 = lists:filter(fun ([K | _]) -> K == "To" end, Sep1),
ListAddress = lists:append(Sep2),
[_ | Tail] = ListAddress,
lists:map(fun(Address) -> string:tokens(Address, ",") end, Tail).
如果我有,例如短消息:https://gist.github.com/865910 我io:format(Sep1)
https://gist.github.com/865905了,它的確定都沒有:
但是,如果我有附件長消息: - https://gist.github.com/865914 我得到了io:format(Sep1)
- https://gist.github.com/865906一切都保持原樣:
怎麼了?爲什麼拍攝消息正常解析和大消息不解析?
當我嘗試使用正則表達式:
List = binary_to_list(Binary),
re:run(List, "^To: (.)*$", [multiline, {capture, all_but_first, list}]).
我只得到{match, ["m"]}
爲什麼?
謝謝。
您必須使用括號的點星'的'外,否則你會只匹配第一個字符。 – 2011-03-11 16:49:03