re = /<(.+)>([^<>]*)<\/\1>/m
str = ' <Interceptor>
<AttackCoords>-80.03107887624853,25.351308629611</AttackCoords>
<Outcome>Interdiction</Outcome>
<Infiltrators>6</Infiltrators>
<Enforcer>Assured</Enforcer>
<ActionDate>2013-11-03</ActionDate>
<ActionTime>04:40:00</ActionTime>
<RecordNotes>Infiltrators:
Savanna Carrera,
Gregoria Farías,
Julina Abeyta,
Mariquita Alonso,
Urbano Briseño,
Victoro Montano </RecordNotes>
<NumEscaped>3</NumEscaped>
<LaunchCoords></LaunchCoords>
<AttackVessel>Raft</AttackVessel>
</Interceptor>'
# 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