use strict;
my $str = '*044*05/02/2013*14:24*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
OPERATION OK
*044*05/02/2013*14:24*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
*044*05/02/2013*14:24*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
OPERATION OK
[0r(1)2[000p[040qe1w3h162*054*05/04/2013*14:27*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
*055*05/04/2013*14:27*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
OPERATION OK
[020t*057*05/04/2013*14:27*
[05p
BNA CNTRS
LAST CLEARED : 00/00/00 00:00
COUNT
ENCASHED 141
[0r(1)2[000p[040qe1w3h162*065*05/05/2013*14:30*
*1234*1*(Iw(1*0, M-00, R-10011002100310041
A/C
OPERATION OK
*071*05/06/2013*14:31*
*1234*1*(Iw(1*1, M-00, R-10011002100310041
A/C
CUSTOMER CANCEL
[020t*076*05/06/2013*14:32*
[05p
BNA CNTRS
LAST CLEARED : 05/04/13 14:28
COUNT
ENCASHED 11';
my $regex = qr/(?=(\d{2}\/\d{2}\/\d{4}))(?=([^\n]+\n)+[^\n]*BNA\sCNTRS[^=\n]*\n)([^\n]+\n)+/sp;
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