$re = '/^La.+?no\s*(?\'num_externe\'.+?)\s.*\s(?:^.*\n)*.*installation\s*:\s*(?\'ins_numins\'.+?)\s+.*:\s*(?\'apt_localisation\'.+?)\s+.*:\s*(?\'apt_nom\'.+?)\s+.*:\s*(?\'apt_email\'.*?)\s+Typologie:.*\s*Motif.+?:\s*(?\'qsy_lib\'.+?)\s*Demande:\s*(?\'commentaire_externe\'.+)/m';
$str = 'Demandes - Date: 03/06/2019 à 09:58
La demande no 117530 a été externalisée à NORD ENGIE-Cofély,
Site concerné:
- Numéro d\'installation : 2870521005
- Nom du Site : APE ST YRIEIX
Chargé d\'affaire: Aurelie GUILLON
Email:
Typologie: Forfait heures multiservices
Motif détaillé: Demande
Demande: Objet : fixer la boîte à pharmacie petit format au mur. Bonjour, Je sollicite une intervention pour fixer la boîte à pharmacie petit format au mur en zone d\'accueil à côté de l\'extincteur. Cordialement. Sylvain CLUZEAU.
';
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