use strict;
my $str = ' 12 | 11 | 5
13 | 3 | 13
5 | 16 | 3
15 | 2 | 20
8 | 5 | 16
4 | 12 | 3
20 | 1 | 14
9 | 1 | 1
15 | 13 | 14
15 | 1 | 1
18 | 15 | 5
5 | 1 | 18
13 | 9 | 8
16 | 1 | 1
5 | 5 | 14
7 | 17 | 10
8 | 13 | 20
12 | 2 | 20
8 | 14 | 3
14 | 11 | 18
6 | 11 | 14
19 | 12 | 3
8 | 7 | 13
8 | 3 | 20';
my $regex = qr/^\s{8,9}\d{1,2}\s{2}\|\s{9,10}\d{1,2}\s{2}\|\s{9,10}\d{1,2}$/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