use strict;
my $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';
my $regex = qr/TRN.*FRLPD\s+FRPLY.*\s*FRLPD\/([\w\s]*).*FRPLY\/([\w\s]*)\//imp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html