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.
'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html