$re = '/(?<type>[A-Z]{1})(?<subtype>[A-Z]{1})(?<country>[A-Z]{3})(?<last_name>[A-Z<]{25})(?<department>[A-Z0-9<]{3})(?<office>[0-9<]{3})\n(?<id_card>[A-Z0-9]{12})(?<id_check>[0-9]{1})(?<first_name>[A-Z<]{14})(?<birth_date>[0-9]{6})(?<birth_check>[0-9]{1})(?<gender>[MF]{1})(?<full_check>[0-9]{1})/';
$str = 'IDFRALOISEAU<<<<<<<<<<<<<<<<<<<<<<<<
970675K002774HERVE<<DJAMEL<7303216M4
IDFRAPALERMO<<<<<<<<<<<<<<<<<<061773
1309061227772BIANCA<<HELLY<8911205F7
IDFRAPETE<<<<<<<<<<<<<<<<<<<<<952042
0509952018746NICOLAS<<PAUL<8206152M3';
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