use strict;
my $str = 'Test String
2571130,733 5533151,436 E5015 6 16 E5015 16
2576626,674 5531614,498 E5090 6 16 E50900 16
2576614,102 5531577,319 E50/17 1 16 E50/17 16
2567054,088 5538296,751 E5018 6 16 ;E5018 16
2576606,227 5531589,142 E5070 6 16 Ei5070 16
2584724,341 5502054,434 R7070 6 17 F7070 16
2584735,918 5502107,131 R7014 6 17 R7014 16';
my $regex = qr/(E)(?=\d{4})/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