re = /<NumDI>(?'num_externe'.*)<\x2FNumDI>.*<NomDemandeur>(?'apt_nom'.*)<\x2FNomDemandeur>.*<Installation>(?'ins_libl'.*)<\x2FInstallation>.*<Localisation>(?'apt_localisation'.*)<\x2FLocalisation>.*<Symptome>(?'tsy_lib'.*)<\x2FSymptome>.*<SousSymptome>(?'qsy_lib'.*)<\x2FSousSymptome>.*<DateSouhaitee>(?'dtheure_limite'.*)<\x2FDateSouhaitee>.*<Commentaires>(?'commentaire_externe'.*)<\x2FCommentaires>/m
str = '<DEMANDE> <NumDI> 247902</NumDI> <NomDemandeur>BOURG</NomDemandeur> <Installation>84CA21558</Installation> <Localisation>ZAC,,,</Localisation> <Symptome>CHA2</Symptome> <SousSymptome>CHA2</SousSymptome> <Urgence>1</Urgence> <DateSouhaitee>15/05/2019</DateSouhaitee> <Commentaires>TEST DE CREATION DE DEMANDE</Commentaires> </DEMANDE> '
# 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