$re = '/(?<type>[A-Z0-9]{1})(?<subtype>[A-Z0-9<]{1})(?<issue_country>[A-Z0-9]{3})(?<doc_number>[A-Z0-9<]{9})(?<check_sum>[A-Z0-9]{1})(?<first_optional>[A-Z0-9<]{15})\n(?<date_brith>[A-Z0-9]{6})(?<birth_check>[A-Z0-9{1}])(?<sex>[A-Z0-9]{1})(?<expiration_date>[A-Z0-9]{6})(?<expiration_check>[A-Z0-9]{1})(?<nationality>[A-Z0-9]{3})(?<second_optional>[A-Z0-9<]{11})(?<check_digit>[A-Z0-9]{1})\n(?<lname>[A-Z0-9]+)(?<lname2><[A-Z0-9]+){0,}<<(?<spacing>[<]{0,})(?<fname>[A-Z0-9]+)(?<mname1><[A-Z0-9]+){0,}(?<complement><.+){0,}/';
$str = 'IDCHES0002068<8<<<<<<<<<<<<<<<
8102287F1301014CHE<<<<<<<<<<<4
VADIS<<QUO<<<<<<<<<<<<<<<<<<<<
I<NLDXI020DF236123456783<<<<<<
7208148F1108268NLD<<<<<<<<<<<9
VAN<DER<STEEN<<MARIANNE<LOUISE';
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