用于解析多部分/混合体的正则表达式

时间:2014-07-10 21:08:22

标签: javascript regex multipart

我想要一个javascript的正则表达式来解析multipart / mixed body。例如,在以下内容中:

这是一条包含MIME格式的多个部分的邮件。

 --frontier
 Content-Type: text/plain

 This is the body of the message.
 --frontier
 Content-Type: application/octet-stream
 Content-Transfer-Encoding: base64

 PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg
 Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==

结果应该是以下字符串的数组:

 [**"Content-Type: text/plain
 This is the body of the message."**,

 **"Content-Type: application/octet-stream
 Content-Transfer-Encoding: base64
 PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg
 Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg=="**]

0 个答案:

没有答案