Level 73
It's probably because Windows and *nix systems has different line endings.
Windows has \r\n while *nix has \n.
https://www.cs.toronto.edu/~krueger/csc209h/tut/line-endings.html
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am working on extracting binary data from a soap response:
This is the my preg_match pattern:
$pattern = '/Content-ID: <' . preg_quote($contentId) . '>\r\n\r\n(.*?)\r\n--MIMEBoundary/s';
It does not match the below binary data as expected. if I change it to
$pattern = '/Content-ID: <' . preg_quote($contentId) . '>\r\n\r\n(.*?)--/s';
If will work. I don't understand why it won't match the return and newline and more baffled that it won't match with --MIMEBoundary included..
This is the section I am searching, only include a sample of the binary data for simplicity :
Content-ID: <[email protected]>
^«ô?C].TPãÝ¡Æ<9a>·<95>&Ý^A?ðà'fòóxÉ>=<82><9d>@t<88>Âlñ<8c><8b>ýI^N¸§<96>d<95>ZÝÊ^YôK^KlÁÀê<9c>^WÒÅ^^Öw<8e>Â;gü½("û<82>^C×ÎUò^N#=^<99><95>L¼µî2<87>Ú<9b><83>×¢^L^RB<83>^S^C&ç<92>tÜ+ÄDÝ6N<81>øà"ó8ÆT<88>¨<[<88><9e>/¾uÞ^UK<84>©úÀ½ÿ<92>K^_^Wî<86>0QûßÓÏÆ<96><86>8}<87>6\^@ý&<88><±e©õÏnòçÁ^Q¦<8d>JDcö4<Ô<8b>7sÃI$¤<9b><92>Å<96><97>ÒÁ<88>hE^Z<88><8a>¹<8c>¾ñ¥r<88>J^Z<8e>xΩïlû^@Z\Øè|_y<8a>8s^AÙ<89>Åu^Z<8e>Vâ¾:<8c>
)º^Z .($^_ðø<9b>ç¢<99>_¼ñð^T<94>i²1Þ<97>É·:<83>.<9f> ?<84><9f><91>B<9b>.^ÇJø½à 1Ã,?Àí<86>N<89>.whÖÆæCø¤LfýÖ%^Oc½^KÕ<9a>^DtmÙÓÈèzz"pÈG ^]Tõ1ƨ^Wy<92>»@fHNr3<84>â^E<8b>e^X®é<86>~XðÄNÃó¡^@<85>È;i<96>Oè¢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$<9c>ö4._<87>^^^Q<Hª^?^DPÆð<86>Ê<86>^Cþ<9f><93><9c>gQf{Ô¬áW;<80><9f>p<86>îXèy-<87>¢µ<84>î¡We=<89>å^C
ö!´¤Ë^\â£æV<8d>^<96>æPÛ<92>{þ¤
<92>7]<97>]<97>¸@^Eí<87><99>G»ùF^Cj¦©tO<8e>Â;|^M
--MIMEBoundary_61b620e491c281b527e13659743670650c63e7a934d192e2--^M
Please or to participate in this conversation.