我尝试从mime邮件中获取TO:user@mail.com字段。
我有代码:
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一切都与:
怎么了?为什么没有解析消息正常解析和大消息?
当我尝试使用regexp时:
List = binary_to_list(Binary),
re:run(List, "^To: (.)*$", [multiline, {capture, all_but_first, list}]).
我只获得{match, ["m"]}
为什么?
谢谢。
答案 0 :(得分:2)
尝试使用正则表达式:
1> Data = <<"...">> % Your long message
<<"...">>
2> re:run(Data, <<"^To: (.*)$">>, [multiline, {capture, all_but_first, binary}]).
{match,[<<"shk@shk.dyndns-mail.com">>]}