0

I want a regular expression for javascript to parse a multipart/mixed body. For example, in the following:

This is a message with multiple parts in MIME format.

 --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==

The result should be an array of the following strings:

 [**"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=="**]
Jonathan M
  • 17,145
  • 9
  • 58
  • 91
user292167
  • 187
  • 1
  • 4
  • 14
  • 1
    possible duplicate of [parsing a formdata object with javascript](http://stackoverflow.com/questions/12066640/parsing-a-formdata-object-with-javascript) – Jonathan M Jul 10 '14 at 21:13
  • I am trying to find a way using regex and w/o performing a "for" loop – user292167 Jul 10 '14 at 21:35
  • @user292167: Why would you? Regex seems to be the wrong tool for this job. And why don't you just do `content.split("--frontier")`? – Bergi Jul 11 '14 at 00:46

0 Answers0