0

I'm using a parsing service and we get the following headers string when an email is received:

Message-ID: <4f2c2c98.1007650a.68f6.ffff9ed6@mx.google.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_NextPart_000_00EB_01CCE26A.183F8AD0"
X-Mailer: Microsoft Office Outlook 12.0

Unfortunately i'm weak at regex and wondering how to extract the boundary and content type to end up with just:

[:content_type] => multipart/mixed
[:boundary] => ----=_NextPart_000_00EB_01CCE26A.183F8AD0
CodeOverload
  • 47,274
  • 54
  • 131
  • 219

2 Answers2

1

This regex will match the text:

/Type:\s{0,}(.*?);\sboundary=\"(.*?)\"/

Note the two capture groups for the data you want.

Richard Brown
  • 11,346
  • 4
  • 32
  • 43
0

Based on the allowed characters the regex would be something like this.

boundary=\"?([a-zA-Z0-9'\(\)+_,-.\/:=? ]*)(?<! )\"?
Adam Eri
  • 889
  • 7
  • 13