$re = '/(?P<headers>.*)[\r\n][\r\n](?P<content>.*)/mis';
$str = '------WebKitFormBoundary3JCHTJWwvnOcvnSv
Content-Disposition: form-data; name="_format"
json
------WebKitFormBoundary3JCHTJWwvnOcvnSv
Content-Disposition: form-data; name="rid"
1
------WebKitFormBoundary3JCHTJWwvnOcvnSv
Content-Disposition: form-data; name="avatar"; filename="carlingford.jpg"
Content-Type: image/jpeg
���p��
��T!1"AQa2q�#B�� R�$3b�C���%r�4S�&�5c
Ds��\'ET�d6U��� ��L!1AQaq"��2����#��BR�b$3r����C%4S��s�&5DTc���?�g������F΅%v9��Ge�9�С@#B�\'�y�4!p|hPW%<�8�:n��9�hI�B;�Ж�:R{�8Ћ(�m�:m�*����0��vƄ#��?\'B���BQ����BGo}
;#�a#�΄U��W�x?�E��H��:��#Ռ�t�L�6C�u ��#�R����22����n�c���B�@3ƅ"��ZRN�dv΄�����Д��pB��\'B]�rҥ�����Q���)P�� �R�����R9Y�I&��� =���X?�bI�u��ĮQ���!C�\'dn�}��-n�s�j8 �c$����Q����$�q��� �@�J9$ryԁj�pN�9���B8+*��v�Sih�J}[�W��ґ���R�r�?��h�I�J!�P�?J��+��T���+��Q�)�m
od';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php