re = /TRN.*FRLPD\s+FRPLY.*\s*FRLPD\/([\w\s]*).*FRPLY\/([\w\s]*)\//im
str = '1.TORNEAMPLE/ERIC
2 HHL RT HK1 LYS IN23NOV OUT26NOV PAST
3 TRN 2C 87 6609 AF 31DEC 1 FRPLY FRLPD HK PAST *
4 TRN 2C 87 6628 AF 01JAN 4 FRLPD FRPLY HK1 1800 2007
FRLPD/LYON PART DIEU//FRPLY/PARIS GARE LYON /TGD *
5 MIS 1A HK1 PAR 23MAY-ARCHIVAGES
6 AP 04.74.07.68.39'
# 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