use strict;
my $str = '69 1.0 PKS-EKC-FlYCTRK--Y 2,110.28 2,110.28
70 2.0 ACS-PMM 31.75 63.50
72 1.0 PKS-TR1-CRD 308.14 308.14
73 1.0 QTC-01HZZ-RBER058- 1,725.57 1,725.57
74 1.0 MGS-05B-4TC-120--8 1,222.84 1,222.84
75 1.0 ACS-VGY 98.60 98.60
76 2.0 ACS-VGG 27.27 54.53
77 2.0 ACS-VGQ 110.93 221.86
78 2.0 ECS-ENM--845 1,294.18 2,588.36
80 1.0 FREIGHT 4,188.00 4,188.00
';
my $regex = qr/^(\d{2})\s(\d.\d)\s(\w+(?:-+\w+)*(?:--\w)?-?)\s((?:\d+,)?\d+.\d+)\s((?:\d+,)?\d+.\d+)$/mp;
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